Reputation: 4293
I want to change the hostname of my Ubuntu 18 server.
I tried the usual approach of:
sudo hostname new_name
- for immediate change/etc/hostname
- for persistent changeThen when I reboot, my hostname has changed back.
Confusingly, the contents of /etc/hostname
has also changed back.
I've modified other files in /
and ~
, and those changes survive reboot. So it's not a quirky disk issue.
Upvotes: 2
Views: 1684
Reputation: 4293
On Ubuntu 18 it seems you must do things differently.
sudo hostnamectl set-hostname new_name
Also, if /etc/cloud/cloud.cfg
exists, edit it to change preserve_hostname: false
to true
.
Upvotes: 3