hostname

hostname displays the current hostname.

hostname

-f displays the FQDN.

hostname -f

Set hostname

hostname <name>

This is not saved in /etc/hostname.

To persist:

Caution: this replaces /etc/hostname and edits /etc/hosts.

echo <hostname> > /etc/hostname
hostname -F /etc/hostname

Edit /etc/hosts:

vi /etc/hosts

Append:

<Global IP> [FQDN] <hostname>

Verify

hostname
hostname -f

hostname should show only the hostname. hostname -f should show the FQDN.

SSH name

For updating the SSH name, delete the known_hosts entry.

Updated: 2026 Aug 19