How To Change Hostname on Ubuntu (CLI/GUI)

Command line (CLI) or Graphical User Interface (GUI) can change hostname on Ubuntu or any other Linux server. On Ubuntu, use the command “hostnamectl set-hostname <new-name>” on CLI and go to “Settings > About > Device Name” on GUI to change the hostname.

In this article, we learn how to change hostname on Ubuntu using CLI and GUI without any reboot and with the help of screenshots. You can change the Ubuntu hostname using CLI or GUI (Graphical User Interface).

How To Change Hostname on Ubuntu (CLI and GUI)

What is Hostname?

Changing the hostname on Ubuntu is simple, but before learning that, let’s see what the hostname is.

In simple terms, a hostname is like a unique name tag for your computer. It’s what identifies your computer on a network.

Just like how you have a name that distinguishes you from others (hopefully!), your computer needs a hostname to stand out in the digital crowd.

How to Change Hostname on Ubuntu through CLI

To change hostname on Ubuntu, open the terminal and first check the server hostname using the command “hostnamectl” or “hostname“. This will provide a detailed description of your Ubuntu server/machine.

Also, when you open the terminal, it will generally, show you the hostname.

ubuntu@ub23:~$ hostnamectl
 Static hostname: ub23
       Icon name: computer-vm
         Chassis: vm
      Machine ID: d5920a161aa9410596c2be710fac587a
         Boot ID: 64106b86e87246b5a2f65e59bba13700
  Virtualization: vmware
Operating System: Ubuntu 22.04.2 LTS              
          Kernel: Linux 5.19.0-45-generic
    Architecture: x86-64
 Hardware Vendor: VMware, Inc.
  Hardware Model: VMware Virtual Platform
ubuntu@ub23:~$ hostnamectl set-hostname ubuntu22

Now, once you have confirmed the hostname, again use the hostnamectl command to change the hostname of the Ubuntu server. Below is the complete syntax with the output.

Syntax: hostnamectl set-hostname <new-name>

hostnamectl set-hostname ubuntu22

Note: This does not require a reboot and is permanent. You can open a new terminal and confirm the new hostname.

How to Change Hostname on Ubuntu through GUI

Ubuntu hostname can also be changed using GUI. If you are using GUI on YUbuntu and don’t want to use CLI to change the hostname, just go to Settings and then head over to the About tab.

Change hostname on Ubuntu - Settings

There you will see “Device Name“, clicking on it will give you the option to change the hostname on Ubuntu.

Change hostname on Ubuntu - Device name

Your device name is changed permanently and you do not need to reboot the Ubuntu machine, but if you want to test this, just go ahead and reboot the machine and check the hostname again.


After changing the hostname on Ubuntu, don’t forget to check the /etc/hosts file. If it contains the old hostname, change it to new.


To conclude, we learned how to change the hostname on Ubuntu server without rebooting through the command line (CLI) and Graphical user interface (GUI).

For more such tutorials, don’t forget to bookmark our website.


Q1: Why change the hostname on Ubuntu?

A: There are several reasons for changing the hostname on your Ubuntu system. One common scenario is to provide a more meaningful and descriptive name for your device on the network.

Q2: Can I change the hostname without restarting?

A: Yes, changes take effect immediately, but restart for a full application update. To avoid any potential issues, it is recommended to restart the system after changing the hostname.

Q3: Will changing the hostname affect the internet connection?

A: No, but verify router or DNS settings for proper reflection.

Q4: Can I use special characters in the new hostname?

A: It is advisable to avoid using special characters or spaces in the hostname. Stick to letters, numbers, and hyphens to avoid conflicts.

Q5: Will hostname change impact system security or SSL certificates?

A: Changing the hostname may have implications for security certificates and SSH keys associated with the system. Update certificates and SSH keys tied to the old hostname for secure connections.

Buy me a coffeeBuy me a coffee

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.