Per an older answer, these are all the files necessary to change the hostname?

  • /etc/host.conf
  • /etc/hosts
  • /etc/hostname
  • /etc/sysctl.conf

for Ubuntu 16.04 server LTS on Amazon EC2


There is also

sudo hostnamectl
cat /etc/mailname

If cloud-init is installed you also need to change


Set preserve_hostname: true

Consider also to change machine-id and ssh-key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.