Bobcares

How to Permanently Change the Hostname on Ubuntu

by | May 23, 2024

Learn how to permanently change the hostname on Ubuntu. Our Server Management Support team is here to help you with your questions and concerns.

How to Permanently Change the Hostname on Ubuntu

Did you know that changing the hostname on your Ubuntu system is as easy as 1-2-3 and can be done without rebooting?

How to Permanently Change the Hostname on Ubuntu

Our experts have put together these steps to help you out:

  1. First, we have to check the current hostname. So, open a terminal.
  2. Then, run this command:

    hostnamectl

    This command displays the current hostname along with other system information like architecture and kernel version.

  3. Then, run the following command to change the hostname:

    sudo hostnamectl set-hostname newhostname

    Remember to replace `newhostname` with our desired hostname.

    This command changes the static (standard), transient (dynamic), and pretty (descriptive) hostnames all at once.

  4. Furthermore, we can change certain types of hostnames using additional options:
    • Static Hostname:

      sudo hostnamectl set-hostname --static newhostname
      This updates the `/etc/hostname` file with the new static hostname without changing the transient or pretty hostnames.

    • Transient Hostname:

      sudo hostnamectl set-hostname --transient newhostname

    • Pretty Hostname:

      sudo hostnamectl set-hostname --pretty "New Hostname"

    Note that the pretty hostname can contain spaces and special characters, while static and transient hostnames should stick to letters, numbers, and hyphens.

  5. After changing the hostname, verify it by running:

    hostnamectl

  6. If the hostname hasn’t changed, we may need to restart the `systemd-hostnamed` service:

    sudo systemctl restart systemd-hostnamed

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to permanently change the hostname on Ubuntu.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.