The hostname is the name of a device that is used to identify your device name over the internet. It gives us the device name information with which we interact physically or on the network without remembering many IP addresses. The hostname is shown on some prominent locations in your system such as in Linux on the terminal prompt.
For our convenience, we can change the hostname of a system in Linux and other operating systems. But, it is necessary to pick some descriptive hostname for your device such as “ubuntu-desktop” instead of choosing an ambiguous one.
This article will demonstrate how to change the hostname in Ubuntu 22.04 Linux Jammy Jellyfish system. We will explore the list of all possible methods used for changing the hostname in Linux distributions.
We can change the hostname in Ubuntu 22.04 LTS system by following the two different methods:
Most Ubuntu users want to change the hostname using the Gnome desktop environment. Therefore, we can change the hostname using the GUI after performing the following steps:
$ hostname
This command shows you the updated hostname in the output.
Changing the hostname in Ubuntu 22.04 using the command line is quite a simple and easy process. First, print the current hostname of your device. You can check the hostname of your system either by using the “hostname” or via the “hostnamectl” command:
$ hostname
The “hostnamectl” command shows you more information about the hostname.
$ hostnamectl
Different ways are available to change the hostname in Ubuntu using the terminal.
The hostname command allows you to temporarily change the hostname of your system.
$ sudo hostname linuxhint
Most Linux distributions including Ubuntu 22.04 have a command line tool “hostnamectl” to manage the system hostname. Using the hostnamectl command, you can change your device name. This command allows you to change the hostname permanently without rebooting your system.
$ sudo hostnamectl set-hostname linuxhint
We can change the hostname by directly modifying the configuration file. But, after changing the hostname, you need to restart your system to make the changes take effect!
Open the configuration file “/etc/hostname” and edit it using the following command:
$ sudo nano /etc/hostname
Now, replace the hostname with your new hostname:
Press “Ctrl+O” to save the changes and “Ctrl+x” to exit from this window.
No matter which method you are using to change the hostname, after changing the hostname, it is recommended for you to also do these changes in the configuration file “/etc/hosts”. This configuration file contains the old hostname, IP mapping, etc. It is important to change the hostname in this file. To edit the hostname in the “/etc/hosts” file, open this file:
$ sudo nano /etc/hosts
Now, do the following changes:
127.0.0.1 localhost 127.0.1.1 linuxhint
Save the changes by pressing “Ctrl+O” and then “Ctrl+X” to exit from this screen.
In this tutorial, we learned how to change the hostname in Ubuntu 22.04 LTS Jammy Jellyfish Linux distribution. Changing the hostname is a simple and small task that we can do using multiple ways. In this tutorial, we changed the hostname using two different methods using the terminal and GUI. I hope all the discussed details are informative for you.
Today, IBM announced the launch of their latest server: the new IBM LinuxONE Emperor 5.…
Welcome to the Ubuntu Weekly Newsletter, Issue 890 for the week of April 27 –…
Singapore | May 27, 2025 | Full-day event How do you build robust, performant edge…
Kolla Ansible provides production-ready containers (here, Docker) and deployment tools for operating OpenStack clouds. This…
This public beta enables the full Ubuntu Desktop experience on the Qualcomm Dragonwing™ QCS6490 and…
Time is running out to be in full compliance with the EU Cyber Resilience Act,…