Gangmax Blog

自由之思想,独立之精神

How to Change Hostname in Ubuntu

Run the following command to change the hostnames in the files:

1
sudo vi /etc/hostname
2
sudo vi /etc/hosts

Then restart the computer. The hostname should be the new one.

Note:

If you didn’t change the hostname in the “/etc/hosts” files, you will get “unable to resolve host …” error when running the command:

1
sudo apt-get clean

I referred here and here.

Comments