Here are the steps to change the Ubuntu hostname.

To check your current hostname and summary of your machine.


There a few ways to change your hostname.

sudo hostnamectl set-hostname <new hostname>

# Manually changing it in the hostname file
sudo nano /etc/hostname

# To update the prompt immediately you can issue
sudo exec bash

After changing the hostname you might want to change/add the new name to the hosts file.

sudo nano /etc/hosts

A sample of the hosts file.