1

I am new to ubuntu and I am trying to change hostname of my ubuntu server 18.04.2 LTS. I've already changed /etc/hostname and /etc/hosts and rebooted. But it didn't work.

My files: /etc/hostname:

ubuntu-s2

/etc/hosts:

127.0.0.1 localhost.localdomain ubuntu-s2

::1 localhost6.localdomain6 localhost6

::1 localhost ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters ff02::3 ip6-allhosts

Is the only way to do it to change preserve hostname to true in /etc/cloud/cloud.cfg?

1 Answer 1

0

You are missing one thing:

hostnamectl set-hostname ubuntu-s2

After that, reboot. Your hostname will then be ubuntu-s2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .