Ubuntu 20.04 LTS change hostname permanently

To change the hostname of an Ubuntu 20.04 LTS system permanently, you can use the hostnamectl command. Here are the steps to change the hostname:

  1. Open a terminal window and run the command hostnamectl set-hostname new-hostname replacing “new-hostname” with the desired hostname.
  2. Verify the new hostname by running the command hostnamectl.
  3. To make the change permanent, you will need to edit the /etc/hostname file. Use your preferred text editor to open this file and replace the current hostname with the new one.
  4. Also, you should check and edit the /etc/hosts file, this file should contain the IP address of your host and the new hostname.
  5. After making the changes, save the file and close the text editor.
  6. Finally, reboot the system for the changes to take effect.

It’s important to note that the hostname is used to identify your system on the network, so you should choose a hostname that is unique and meaningful. Also, it’s good practice to use lowercase letters and numbers for the hostname.

Also, it’s always a good idea to have a backup of the files you will be editing and to take note of the original contents of the files, in case you need to revert the changes.

Leave a Comment