Change computer name permanently in Linux

In Linux , systems based on Debian or Ubuntu , from the console to change the name of the computer you have to touch two configuration

files /etc/hosts and /etc/hostname

We first edit the /etc/hostname file

sudo vim /etc/hostname

And we change the name it has to the new name

Then we edit the /etc/hosts file

sudo vim /etc/hosts

And we change newhostname  for the new name We restart

127.0.1.1 myhostname
127.0.0.1 localhost
127.0.1.1 newhostname

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

the computer and when we log in again it already has the new name

And that’s all folks!!
Thank you for following me and reading me, I hope it has helped you
Greetings
Alex.

Leave a Reply