×



A system hostname is an entity that is used to uniquely identify a system within a network. It is also known as the device name of a system. This name is usually assigned to your system when you install an operating system on it. 

However, at times, you may feel like changing that previously set host name or device name for any reason.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Ubuntu related queries.

In this context, we shall look into methods to change your hostname on Ubuntu 20.04.


How to change Hostname on Ubuntu 20.04 ?

To change the Hostname on a Ubuntu 20.04 system, you can apply the different methods below.


Method 1. The GUI based Method for Changing the Hostname on Ubuntu 20.04

You can follow the steps given below to change the Hostname of your Ubuntu 20.04 system using the GUI based method.

1. Access your Ubuntu 20.04 System's Settings:

First, you have to search for Settings in your Activities search menu and then click on the Settings search result.


2. Switch to the About Tab in the Settings Window and Click on the Current Device Name:

In the Settings window, you need to switch to the "About" tab. 

Here, you will be able to see an entry titled Device Name which in fact, refers to your hostname. 

You need to click on this entry to change it.


3. Change your Hostname on Ubuntu 20.04:

When you will click on the Device Name entry, a dialogue box will appear on your screen. In this dialogue box, you can type in a new hostname in the space provided and then click on the Rename button.


4. Verify your Changed Hostname on Ubuntu 20.04:

Finally, you can verify the changed hostname by looking at the Device Name entry now.


Method 2. The "hostnamectl" Command Method for Changing the Hostname on Ubuntu 20.04

To change the Hostname of your Ubuntu 20.04 system using the “hostnamectl” command method, you will have to perform the following steps.

1. Check the Current Hostname of your Ubuntu 20.04 System:

First, you need to check the current hostname of your Ubuntu 20.04 system with the command shown below:

$ hostnamectl

2. Change the Hostname of your Ubuntu 20.04 System using the "hostnamectl" Command:

Now, we can change this hostname by executing the command shown below:

$ hostnamectl set-hostname new-hostname

Instead of new-hostname, you can type any new hostname of your choice.


3. Verify your Changed Hostname on Ubuntu 20.04:

You can confirm if the hostname has been changed or not by executing the "hostnamectl" command once again. 

From the output of this command, you can verify that the hostname of your Ubuntu 20.04 system has been changed.


Method 3. The File based Method for Changing the Hostname on Ubuntu 20.04

To change the Hostname of your Ubuntu 20.04 system using the file-based method, you will have to perform the following steps:

1. Change the Hostname in the "/etc/hostname" File on Ubuntu 20.04:

First, we need to access the /etc/hostname file with the following command:

$ sudo nano /etc/hostname

This file will contain your current hostname.

You can replace that hostname with any new hostname and then you can save this file.


2. Change the Hostname in the "/etc/hosts" File on Ubuntu 20.04:

Now, we need to access the /etc/hosts file with the command shown below:

$ sudo nano /etc/hosts

This file contains the IP addresses corresponding to hostnames. You can locate the hostname that you wish to change.

Now, type in a new hostname after which you can save this file.


3. Reboot your Ubuntu 20.04 System:

For the changes that you have just made to take effect, you have to reboot your Ubuntu 20.04 system with the following command:

$ sudo systemctl reboot


4. Verify your Changed Hostname on Ubuntu 20.04:

Once your system is rebooted, you can verify your changed hostname by executing the "hostnamectl" command yet again. 

The output of this command will reveal that your hostname has been changed successfully.


[Need urgent assistance in configuring the hostname on any Linux Distributions? We are here to help you today. ]


Conclusion


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com