Change an Ubuntu Hostname
I recently had to change the hostname on an Ubuntu machine. There are three steps which I did not find documented together.
- Modify the file /etc/hostname:
$ sudo vim /etc/hostname
- Update the hosts file /etc/hosts so that it has an updated name pointing to its own ip address:
$ sudo vim /etc/hostname
- If you want to do this without actually restarting the system you'll need to manually tell the machine it has a new hostname by running the hostname command(optional):
$ sudo hostname


