Gangmax Blog

How to Change Hostname in Ubuntu

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

1
2
sudo vi /etc/hostname
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