How to change the hostname on an Ubuntu machine

You can follow this step by step instruction to change the hostname (computer name in Windows world) of a Linux Ubuntu machine.  You will need root (administrator) previliges for performing this, we will use sudo to perform most commands.

1. sudo nano /etc/hostname
This will open up the hostname file in yout text editor, simply change the name in there to the name you want. Save the file with the same name (in Nano, to save the file, hit ctrl + x)

2. sudo nano /etc/hosts
In this file, you want to change the entry next to localhost and make it the same as the hostname of this computer. Save the hosts file

3. sudo shutdown -r now
This will restart your workstation and bring the changes into effect.

4. Log back on to your workstation after the reboot and try pinging your hostname, it should resolve to localhost