Ubuntu How to Change Hostname?
Contents

Start a new terminal to see the new hostname.

For Ubuntu server without a GUI, run sudo vi /etc/hostname and sudo vi /etc/hosts and edit them one by one.

In both files, change the name to what you want and save them.

Finally, restart your computer to apply the changes.

How can I change hostname in Ubuntu 18.04 permanently?

Ubuntu 18.04 LTS change hostname permanently

  • Type the hostnamectl command : sudo hostnamectl set-hostname newNameHere. Delete the old name and setup new name.
  • Next Edit the /etc/hosts file: sudo nano /etc/hosts. Replace any occurrence of the existing computer name with your new one.
  • Reboot the system to changes take effect: sudo reboot.

How can I permanently change my hostname in Linux?

Change a server’s hostname

  1. Using a text editor, open the server’s /etc/sysconfig/network file.
  2. Modify the HOSTNAME= value to match your FQDN hostname, as shown in the following example: HOSTNAME=myserver.domain.com.
  3. Open the file at /etc/hosts.
  4. Run the hostname command.
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest