« HOWTO Enlarge A VMware DiskHOWTO get a Packard Bell scanner working. »

HOWTO To Change The Hostname

26/07/08

HOWTO To Change The Hostname

So for whatever reason you need to change the hostname of your Ubuntu Linux machine. For me this is usually because I am playing around with a copy of a Vmware machine and well its needs a unique name. :)

Follow up:

Check your host name is set to something and no errors are returned. The commands below will return the haost name with an without the domain.

uname -a 
uname -n 
hostname -a 
hostname -f

Make backup copies of the two files, just in case :)

cd /etc 
cp hosts hosts.bak 
cp hostname hostname.bak

Sort out the /etc/hosts file so that the new name is reflected in that file

127.0.0.1   localhost 
127.0.1.1   newhostname.example.com newhostname 

Update the hostname file so that it reflects the new name.

Edit /etc/hostname
sudo nano /etc/hostname
sudo reboot

Once the machine has rebooted use check that the new name is set correctly

uname -a 
uname -n 
hostname -a 
hostname -f

There you go all done!


No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
What can birds and aeroplanes both do?
antispam test