Change Hostname on Ubuntu

You can change the hostname on ubuntu via the terminal using the following command

sudo hostname [newhostname]

You may need to open up a new terminal window for you to see this change. To make this persistent, you can edit the following two files by replacing the previous hostname to the new one.

sudo nano /etc/hostname
sudo nano /etc/hosts

If you wanted to give this a reboot, you will see that this is now using the new hostname!