How to change a server's hostname
Update the following files:
- /etc/hosts
- /etc/hostname
Ubuntu 18.04
See current hostname and related info:
hostnamectl
Change hostname:
hostnamectl set-hostname my_new_hostname
Update /etc/hosts
if necessary.
If cloud-init
is installed, edit /etc/cloud/cloud.cfg
preserve_hostname: true
Postfix
- update
/etc/mailname
- update
/etc/postfix/main.cf
- restart postfix