Linux Commands

Change Hostname on Ubuntu with GUI and CommandLine

In a computer, a networking hostname is a label assigned to a device and used as identification of a specific device over a network. The hostname is a name of a device that is set during the installation of the operating system.

The hostname of a device can be changed anytime, no matter what desktop environment you are using.

This post is focusing on various methods to change the hostname of your device specifically for Ubuntu users.

How to Change Hostname on Ubuntu 20.04 (LTS) and 20.10?

The hostname can be renamed in two different ways, either via GUI or through the terminal:

1. Changing Hostname through GUI:
On Ubuntu desktop, right-click to get the Settings menu:

After this, the “Settings” window will appear with numerous options. Find the “About” option, click on that to see the relevant settings:

Clicking on the “Device Name”, as shown in the above image, a dialogue box will appear and ask you to rename the hostname.

Change the current hostname according to your choice and hit on Rename button to save the new hostname.

2. Change Hostname Through Terminal:

Check Current Hostname

To change hostname using the command line, first, we need to check its current name, which can be found using any of two commands:

$ hostname

Another choice is using the following command that will show you the detailed status of your system:

$ hostnamectl

Change Hostname

The syntax of the command to change hostname is:

$ hostnamectl set-hostname [new-hostname]

Replace the new-hostname with your desired name. You won’t get any output or notification on the terminal, but it will be changed in the backend.

For example:

$ hostnamectl set-hostname linuxhint

To verify it, type “hostnamectl” to get the output:

Pretty Hostname

Many people wish to set the pretty hostname for their devices, to do so, follow the below-given process.

First, let’s check the syntax of the pretty hostname command:

$ hostnamectl set-hostname “new-hostname” --pretty

Now, replace “new-hostname” with your own choice. I will use “Linuxhint Desktop”. So, the command will be like this:

$ hostnamectl set-hostname “Linuxhint Desktop” --pretty


The hostname is an identity of a device over a network and can be modified anytime. We have gone through a detailed guide on how to change the hostname on Ubuntu and learned two easy approaches. The hostname can be changed through GUI or command-line. So, pick the technique you want and follow the steps.

About the author


Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.