A hostname is a customized name assigned to a Linux machine for your device’s DNS (Domain Name System). Hostname differentiates your device from other devices in your local network.
Do you want to change the hostname in Linux for a different server and don’t know how to change it? In this write-up, the methods to change the username on Ubuntu 22.04 will be discussed.
How to Change Hostname in Ubuntu 22.04?
You can change the hostname in Ubuntu 22.04 using the below different methods:
- Change Hostname Using GUI
- Change Hostname Using Command Line
Let’s discuss both methods in detail.
Method 1: Change Hostname Using GUI
In this method, we will elaborate on every step to change the hostname using GUI.
1. Open Hostname Settings
To change the username in Ubuntu 22.04 using the GUI method, click on “Show Applications” from the Dock panel. A new window will open with a search bar, put “hostname” and search. Now, you will see the “Settings” option; click on it to open the computer settings.
2. Open the Device Name
It will take you to the “About” section of the system, and the device name (In my case: Alfred) will show.
To change the device name (username/hostname in the terminal), click on the “Device Name”.
3. Change the Device Name
Now, change your existing device name with your new device name and click on “Rename”.
4. Verify New Device Name
You can verify the new device name from the “About” settings of the device. The below device shows the device name has changed to the new name.
Now, let’s discuss how to change the username using the terminal.
Method 2: Change Hostname Using Command Line
To change the hostname from the terminal, follow the below simple steps:
1. Get the Hostname
Do you want to get the existing hostname in Linux? check the current hostname of the device by executing the below command.
The output shows the username is “Alfred”.
2. Set the New Hostname
Now, We need to set the username in Linux to a different name. The general syntax to change the command is “sudo hostname <new_username>”. Change the username by running the following command:
$ sudo hostname mylinuxblog
3. Verify the New Hostname
Now, run the below-mentioned command to verify the new hostname:
The output shows that the username is changed successfully to the new username.
That’s it from this guide!
The hostname in Ubuntu 22.04 can be changed using the GUI and Command Line methods. To change the hostname through GUI, go to “Settings”, click on “Device Name,” and change the device name to a new hostname. Moreover, to change the hostname using the command line execute the “$ sudo hostname <new_usernaem>” command in the terminal.