Wednesday, June 30, 2010

Change hostname on ubuntu via CLI(Commad Line Interface)

To change the hostname permanently you have to edit two files /etc/hosts and /etc/hostname

Edit the file using your favourite text editor

In /etc/hosts add a new line which look like this

IP domain shortdomainnames

example:
127.0.0.1 linux.local linux

That will add a new local domain, one is the domain long name and the other is the domain shortname.

In /etc/hostname just edit the existing domain with the desired one

Regards.