How to change a server's hostname

From Wiki
Revision as of 18:00, 28 January 2019 by Scott (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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