Change the computer name in Linux (Hostname)
Below instant tutorial on how we can change the computer name in Linux (Hostname) In Debian systems, Ubuntu, The CentOS is literally 2 minutes.
Checking the current name of the server you can be done using the command:
1 | hostname |
or:
1 | hostname -f |
Edit your nano /etc/hosts
1 | nano /etc/hosts |
The file should look like this:
1 2 3 4 5 6 7 | 127.0.0.1 localhost.localdomain localhost 185.38.250.250 node.serwerweb.pl node # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters |
the next step is to edit the file nano / etc / hostname
1 | nano /etc/hostname |
And we enter the hostname node
We make a server restart.
When you log into the console, we can verify all the commands:
1 2 | hostname hostname -f |
1 2 3 4 | root@node:/tmp# hostname node root@node:/tmp# hostname -f node.serwerweb.pl |
for systems CentOS issue the command:
1 | hostnamectl set-hostname nasz nowy hostname |
I also make a server restart.
In case of Ubuntu We use the same principle as a means for Centos
1 | hostnamectl set-hostname nasz nowy hostname |