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:
- Open a terminal window and run the command
hostnamectl set-hostname new-hostname
replacing “new-hostname” with the desired hostname. - Verify the new hostname by running the command
hostnamectl
. - 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. - Also, you should check and edit the
/etc/hosts
file, this file should contain the IP address of your host and the new hostname. - After making the changes, save the file and close the text editor.
- 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.