ubuntu 18.04: permanently change server host name

If you're not happy with leaving an older version somewhere, then simply open the file at /var/lib/cloud/seed/nocloud-net/user-data, and change your hostname at the line:

hostname: cm-lc-nc

Then run:

cloud-init clean
cloud-init init

It will then set /etc/hostname to the new value and will remain consistent across reboots. This will remove all traces of the previous hostname and in the event that preserve_hostname is either reset or ignored for some reason, you still won't lose your new hostname.

Source: https://askubuntu.com/questions/1028633/host-name-reverts-to-old-name-after-reboot-in-18-04-lts

Leave a Reply

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