How to Change Hostname on Ubuntu 20.04

How do you view your hostname?

Step 1 : You need to use the hostname command or hostnamectl command


Step 2 : Output from the hostname command

Setting the hostname

Step 1 :Changing the hostname is fairly simple. To do this, we can use the hostnamectl command as root or with sudo.

sudo hostnamectl set-hostname

Step 2 : Open the /etc/hosts file and change the old hostname to the new one.

sudo nano /etc/hosts

Step 3 : Verify the change


Add Comment