To change the hostname of an Ubuntu 20.04 LTS system permanently, you can use the following steps:
/etc/hostname
file and change the hostname to the desired value. For example:sudo nano /etc/hostnameSource:www.lautturi.com
/etc/hosts
file and change the hostname to the desired value. For example:sudo nano /etc/hosts
sudo reboot
After rebooting, the system will have the new hostname.
Note: Changing the hostname in these files will change the hostname for the current session only. To make the change permanent across reboots, you need to edit the /etc/cloud/cloud.cfg
file and set the preserve_hostname
option to true
. For example:
sudo nano /etc/cloud/cloud.cfg
preserve_hostname: true
This will ensure that the hostname is preserved across reboots.
Keep in mind that changing the hostname can have unintended consequences, such as breaking scripts or applications that depend on the old hostname. It is always a good idea to test the changes carefully before making them permanent.