NixUser

NixUser.com | Unix User | Linux User | NixUser

Set hostname in Ubuntu

In Ubuntu hostname can be set using the hostnamectl command. The command output will be like:

$ hostnamectl

root@server:~# hostnamectl
Static hostname: server.xxxxxxxx.com
Icon name: computer-vm
Chassis: vm
Machine ID: 429381bxxxxxxxxxxxxxxcab5fcd
Boot ID: 1a2xxxxxxxxxxxxxxxxxxb8f28729
Virtualization: xen
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 4.15.0-1057-aws
Architecture: x86-64

To change the hostname, use:

$ hostnamectl set-hostname yourhostname.com