falsePockets
falsePockets

Reputation: 4293

Why does my hostname and /etc/hostname get reset on reboot?

I want to change the hostname of my Ubuntu 18 server.

I tried the usual approach of:

Then 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

Answers (1)

falsePockets
falsePockets

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

Related Questions