How to change the hostname on Ubuntu 16.04?

Follow these simple steps to change the hostname on a ubuntu machine:

Step 1: Update /etc/hostname file

This file contains the current hostname of the machine. Update the name to your

desired name.

$ sudo vi /etc/hostname

Step 2: Update /etc/hosts file

Replace the current hostname in the file with the desired name.

$ sudo vi /etc/hosts

Step 3: Set the hostname using the hostnamectl command

$ sudo hostnamectl set-hostname new_hostname

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s