Linux change release name

Linux change my hostname / computer system name

How to display current hostname

Just type hostname command to print the name of the system on screen:
$ hostname
Sample outputs:

Change the Linux hostname

Set hostname to desktop.nixcraft.com:
# hostname desktop.nixcraft.com
# hostname
Sample outputs:

Change hostname permanently on a Debian/Ubuntu Linux

You need to edit a file called /etc/hostname:
# vi /etc/hostname
Set new hostname:

Save and close the file. You need to reboot the system or run any one of the following command:
# /etc/init.d/hostname.sh start
OR
# invoke-rc.d hostname.sh start

Linux change hostname using hostnamectl command ( systemd only)

Most modern Linux distribution comes with systemd. If you are using systemd based distro try hostnamectl command.

Query hostname with hostnamectl

Let us print out current hostname:
$ hostnamectl

Change hostname with hostnamectl

The syntax is as follows to set hostname to ‘viveks-laptop’:
$ hostnamectl set-hostname ‘viveks-laptop’
Sample outputs:

Fig.01: hostnamectl in action on a Linux based system

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Set the deployment environment description

ENVIRONMENT must be a single word without any control characters. One of the following is suggested: “development”, “integration”, “staging”, “production”. The syntax is:
$ hostnamectl set-deployment ENVIRONMENT
$ hostnamectl set-deployment production

How to set the location string for the system, if it is known

The syntax is:
$ hostnamectl set-location LOCATION
$ hostnamectl set-location «NYC Home»
$ hostnamectl set-location «DC 2, right rack, 2nd shelf»

A note about an RHEL (Red hat) / CentOS / Fedora Linux users

If you are using CentOS or Fedora or Redhat (RHEL) Linux, see this FAQ.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Thanks. That’s exactly what I needed!

hostname papa.nixcraft.com —temp changing the hostname
For Permanent
vim /etc/hosts
vim /etc/sysconfig/network

i did as you tell but can’t ping to hostname. My hostname is linuxserver, when i use command ping it appear connect: Network is unreachable.

after changing, type “bash” and the prompt will change to the newest hostname your just changed.

this just doesn’t work, it seems like it does but you wont be able to use “sudo” anymore…..

hostname change command

Hi,
Thanks for pointing me to the right direction.
As for me and perhaps ppl using certain distro, may have to edit the /etc/hosts file as well.
sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.1.1 newhostnamehere
——
Look for the line that says:
127.0.1.1 originalname
and change it to the newhostname

Regards,
Bob
PS: until I fix this, sudo took a long time trying to but fail to “resolve” the name, before asking for password and the GUI ‘update’ taskbar icon and GUI package manager stop working.

The same thing happened to me, thanks for the comment

hi
my need change host name in centos 5.7 ??

Really from my own point of view it is so amazing to use it please i need some e-book how to use it.
Thanks’
Martin

Setting up a CentOS 6 box today and was able to use the hostname command successfully without errors. Not sure why using the other FAQ is suggested.

Источник

Linux Change or Rename User Name and UID

Linux Change or Rename User Command Syntax

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Est. reading time 5 mintues

The syntax is as follows to rename by user name:
usermod -l login-name old-name

  • We use the usermod command in Linux to rename user account. The name of the user will be changed from the old-name to login_name. Nothing else is changed. In particular, the user’s home directory name should probably be changed to reflect the new login name.

The syntax is as follows to rename by a UID (user ID):
usermod -u UID username
Where,

  • The numerical value of the user’s ID (UID) . This value must be unique unless the -o option is used. The value must be non-negative. Values between 0 and 99 are typically reserved for system accounts. Any files which the user owns and which are located in the directory tree rooted at the user’s home directory will have the file user ID changed automatically. Files outside of the user’s home directory must be altered
    manually.

List all users in Linux system

Type the following cat command:
cat /etc/passwd
One can use the grep command to filter out only user names:
grep -w ‘^username’ /etc/passwd
grep -w ‘^jerry’ /etc/passwd
Another option is to use the cut command:
cut -d: -f1 /etc/passwd
Sample outputs:

How to Change or Rename Username and UID in Linux

Let us see how to rename user login. First, make sure user name is not logged into the server and any other process is not running under the same user name. I also recommend that you backup any data or server files before changing user names.

View current user and group membership for user named tom

First get user identity using the id command:
id tom
Next use the grep command to grab login info about user named tom from the /etc/passwd file
grep ‘^tom:’ /etc/passwd
See group info about user named tom using the groups command:
grep ‘tom’ /etc/group
groups tom
Find home directory permissions for user named tom, run the following ls command:
ls -ld /home/tom/
Finally, see all Linux process owned by user and group named tom using the ps command:
ps aux | grep tom
ps -u tom

Fig.01: Getting info about user named ‘tom’ on a Linux based system

Rename and change username from tom to jerry on Linux

Type the usermod command as follows:
# id tom
# usermod -l jerry tom
## Verify ###
# id tom
# id jerry
# ls -ld /home/tom

A note about running process

You may see an error as follows if tom is logged in and running jobs:

You need to kill all Linux process owned by user named tom and forcefully logged them out of the system:

Rename and change primary groupname from tom to jerry

Type the usermod command as follows:
# id tom
# groupmod -n jerry tom
## Verify it ###
# id tom
# ls -ld /home/tom
Sample outputs:

Fig.02: Sample session renaming user on a Linux based server

How to change user home directory from /home/tom/ to /home/jerry

The syntax is as follows:
# usermod -d /home/jerry -m jerry
# id jerry
# ls -ld /home/jerry
Sample outputs:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

How to change user tom UID from 5001 to 10000

Type the usermod command as follows:
# id tom
# usermod -u 10000 tom
# id tom

Getting help about usermod command

You can pass the —help option to the usermod command. For instance, type the following command at the shell prompt in Linux:
usermod —help

Options Description
-c OR —comment COMMENT new value of the GECOS field
-d OR —home HOME_DIR new home directory for the user account
-e OR —expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f OR —inactive INACTIVE set password inactive after expiration to INACTIVE
-g OR —gid GROUP force use GROUP as new primary group
-G OR —groups GROUPS new list of supplementary GROUPS
-a OR —append append the user to the supplemental GROUPS mentioned by the -G option without removing the user from other groups
-h OR —help display this help message and exit
-l OR —login NEW_LOGIN new value of the login name
-L OR —lock lock the user account
-m OR —move-home move contents of the home directory to the new location (use only with -d)
-o OR —non-unique allow using duplicate (non-unique) UID
-p OR —password PASSWORD use encrypted password for the new password
-R OR —root CHROOT_DIR directory to chroot into
-P OR —prefix PREFIX_DIR prefix directory where are located the /etc/* files
-s OR —shell SHELL new login shell for the user account
-u OR —uid UID new UID for the user account
-U OR —unlock unlock the user account
-v OR —add-subuids FIRST-LAST add range of subordinate uids
-V OR —del-subuids FIRST-LAST remove range of subordinate uids
-w OR —add-subgids FIRST-LAST add range of subordinate gids
-W OR —del-subgids FIRST-LAST remove range of subordinate gids
-Z OR —selinux-user SEUSER new SELinux user mapping for the user account

Conclusion

In this tutorial, you learned how to change or rename username and UID in Linux using the usermod command. Read man pages of usermod(8) and groupmod(8) commands for more information see this page.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How To Find Out My Linux Distribution Name and Version

H ow do I find out what version of Linux distribution I am using from the shell (bash) prompt? How can I tell my Linux distribution name and version using command-line options over ssh-based session?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements lsb_release
Est. reading time 2 minutes

You can use any one of the following method to find out your Linux distribution and name:
a] /etc/*-release file.

b] lsb_release command

c] /proc/version file.

d] hostnamectl command

Method 1. Use /etc/*-release file to display Linux distro version

To find out what version of Linux (distro) you are running, enter the following cat command at the shell prompt:
$ cat /etc/*-release
Sample output from my RHEL v5.x server:

Sample outputs from my Ubuntu Linux v7.10 server:

Method 2. Use lsb_release command To find out Linux distribution name and version

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:
$ lsb_release -a
Sample outputs:

Method 3. Use hostnamectl to find out my Linux distribution name and version

For GNU systemd based distro this is the best option:
$ hostnamectl

What version of Linux am I running?

How do I find out My Linux kernel version?

Type the following uname command:
$ uname -a
OR
$ uname -mrs
Sample outputs:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

  1. Linux – Kernel name
  2. 2.6.32-5-amd64 – Kernel version number
  3. x86_64 – Machine hardware name (64 bit)

Here is output from my SUSE Enterprise Linux server:

Get Linux distribution name and version number in a shell

Say hello to /proc/version

Type the following command to see kernel version and gcc version used to build the same:
$ cat /proc/version
Sample outputs:

Another outputs from my CentOS 7 box:

And SUSE Enterprise Linux server:

This tutorial is also available in a quick video format:

Putting It All Together

Animated gif.01: Finding out Linux distribution name and version with various commands demo

Conclusion

This page showed various commands to figure out what Linux kernel version and Linux distribution your server/desktop/laptop is running.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

But how to find version of other unix systems like FreeBSD. cat /etc/*-release won’t give it

Thanks for giving command cat /etc/*-release
Really this is useful

For FreeBSD uname -a works OK

Well, the article was entitled “HowTo: Find Out My Linux Distribution Name and Version”… 🙂

Generally speaking, “uname -a” will tell you what you need to know. You may need to know a couple of quirks about the O.S. in question. For example, Solaris calls itself “SunOS” (long history there). AIX breaks the version number up into two different uname fields (“5 2” instead of “5.2” – it might even be “2 5” IIRC, which you then have to know to turn into “5.2”). Solaris has an /etc/release.

If you’re going to use /etc/*-release, I would loose the dash

as you’ll pick up a couple more flavors of Unix like that.

“uname” was supposed to be the universal way to do this sort of thing, however, the output varies way too much from vendor to vendor.

PS: Technically, Solaris is a “package deal” consisting of an operating system, an X-Windows package, etc. – 5 things that previously they had not bundled together. So, technically, Solaris 10 (for example) contains an operating system called SunOS 5.10. So when Solaris says “SunOS” in uname, it’s not really incorrect.

This isn’t exactly a general solution. It assumes the distribution supports some LSB stuff, I think.
For debian and slackware, one could try:

On debian stable, lsb-release exists, but just isn’t in /etc/. There is an lsb-release package, and you can run:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 4.0r1 (etch)
Release: 4.0r1
Codename: etch

By the way, lsb_release -a also works on the older Ubuntu version I have.

You can also cat version in proc…

:; cd /proc
;; cat version
Linux version 2.6.9-42.0.3.ELsmp (brewbuilder@hs20-bc1-7.build.redhat.com) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)) #1 SMP Mon Sep 25 17:28:02 EDT 2006

Thanks Richard,
cat /proc/version worked for me..

Thanks alot ! all commands gave some good info about my sys.

And “cat /etc/issue” as well, for my ubuntu 8

Well, that’s all fine well and good for home use, but security people will tell you announcing your o.s. and version in /etc/issue is a bad idea (why give hackers that info?). They will want you to replace /etc/issue with some kind of warning notification (“This computer is only for use by authorized employees of company X. Usage is subject to monitoring. All users are expected to comply with company security policy Y. Unauthorized use is subject is grounds for termination and/or criminal prosecution.”, etc.). Any computer owned by a company that has security people or lawyers, this isn’t going to work on. 🙂

thanx richy. it works

Thanks for the quick command. Worked perfectly.

hi guys,
can this kind of file which contains the version info be modified? for example when I want to remaster Ubuntu to new name with my name: Maxx

do we just to modify a file? or what should we do?

thanks in advance!

hai ,
i read ur information for linux.but, i want “what r the different versions available in linux”.please give ans immediately

would you also like a foot massage with that ??

Ha ha.. Nice one Bro

Please specify the which Linux ? Redhat or else….

Thanks Daniel, that helped on FreeBSD

Hi Daniel, I think your solution will only give the hostname, Kernel, arhitecture etc, but NOT the “distribution name” as is quoted on the question. Havent checked on anyother distro, but at least thats what happens on my CentOS 5.4, the other solutions seem to work.

]# uname -a
Linux myhostname.mydomanin.com 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux

Thanks. Was digging few old linux machines and found this works. Running very old ubuntu 😉

I’m on rhel .. if I type cat /etc/*release I get:
Red Hat Enterprise Linux WS release 4 (Nahant Update 3)

but if I type cat /proc/version I get:
Linux version 2.6.9-34.0.1.EL.ADSKsmp (root@oka) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2))

I’m confused 🙁 so what’s my distribution??

Your distribution is RHEL and your kernel version is 2.6.9-34.0.1.

Both are different.

hi guys
please tyr
FOR UNIX:
#cat /etc/issue
#cat /etc/*-release
#cat /proc/version
#uname -a

FOR Debai/slackware:
#cat /etc/*version

/etc/issue works for Debian too! I use something like this:

This solution works perfect.

Nice example!
Anyhow I can not see why needed the [A-Za-z] part. Please let me know.
So here are the roots of a brand new all platformer ver.sh one-liner…. B-)

cd /etc && cat *_ver* *-rel* /proc/version && uname -a && lsb_release -a

Let us know what does it miss?? (I know – this must be considered as pre-alpha version. B-) some file and command availability should be implemented…)

…. OK – sorry for the OT-like summary here.

R

I typed this in and it worked: cat /proc/version

And this came up : Linux version 2.6.34houkouonchi-web100-ioat-vlan (root@houkouonchi) (gcc version 4.1.2 (Gentoo 4.1.2)) #1 SMP Thu Oct 14 16:27:09 PDT 2010

What distro would this be. I am running my linux through a data center that I have access to.

Oh it would be Gentoo. THANKS! answered my own question =P

thank u .. it works

Thanks, Its really a great tips

smarcell – you are so clever. I am in awe.

but when I type that into the little white box thing, it just says “cat /etc/lsb-release.d: Is a directory”

and I still have no idea what my OS is ;-P

maxx – no you don’t want to change these files or try; what you want to do is something like (just an e.g.) in

/etc/rc.local
#!/bin/sh
#other stuff will be here probably, put your stuff at the end

echo “Hello, you’ve just successfully gained access to Maxx’s computer” > /etc/motd
cat /proc/version >> /etc/motd
echo `uname -a` >> /etc/motd

and so on. you are printing text and the output of programs to the file /etc/motd using shell syntax (the little backticks mean “interpret as a command to run” and echo means “print this” and > means “create a file and send this to it” and “>> means append this to the end of this file”

generally, motd will be printed on login (“message of the day”, quite old school, some systems might not have it I guess. My Scientific Linux 6.1 does. I think ubuntu does. maybe not.)

if not, you can make it yourself and have it in everyone’s .bashrc by editing /etc/skel. For that matter you can put anything you want in .bashrc or .profile and it will run whevever a shell is opened (a bash shell obviously).

/proc isn’t usually somewhere you want to write, unless you know why you are doing it.

please send me linux versions and release dates

Источник

Читайте также:  C windows system32 dllhost exe processid
Оцените статью