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.
The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…
Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…
Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…
Focal Fossa will reach the End of Standard Support in May 2025, also known as…
Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…
Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…