How To Change Hostname on Ubuntu 22.04

In this guide, we want to teach you to Change or Set your Hostname on Ubuntu 22.04.

hostname is used to either set or display the current host or domain name of the system. This name is used by many networking programs to identify the machine. The domain name is also used by NIS/YP.

By default, the hostname of a system is set during the installation of the OS. Even if we install a virtual machine, it is dynamically assigned by the system. But, there may be some conditions whenever we want to change the hostname. The hostname command will let us do so.

Steps To Change Hostname on Ubuntu 22.04

To complete this guide, log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Ubuntu 22.04.

In this guide, we will show you to change your Ubuntu hostname by using the following methods:

  • change hostname using the command line
  • change hostname using GUI

Ubuntu 22.04 – Change Hostname via Command Line

First, you need to check your current hostname on your server by using the following command:

sudo hostname

In my case, it is ubuntulinux.

At this point, you can use the following syntax to change your hostname:

sudo hostname your-hostname

For example:

sudo hostname jammy.jelly

Again check your hostname, you should see that it has been changed.

sudo hostname

Ubuntu 22.04 – Change Hostname via GUI

From your Ubuntu desktop, click on the top right corner where the battery icon, sound icon, and internet icon are displayed. A drop-down menu will pop up. In that menu click on the settings options.

Change hostname ubuntu 22
Change hostname ubuntu 22

From the settings menu, click on About from the first section, click on Device Name.

Then, a message box will open up displaying your previous hostname. Erase that name and insert your new desired hostname and press “Rename”. 

Rename Ubuntu Device
Rename Device

That’s it, you are done.


At this point, you have learned to Change Hostname on Ubuntu 22.04.

Hope you enjoy it. You may be like these articles:

Install and Use Sysdig on Ubuntu 22.04

How To Install OpenSSL 3 on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!