hostname displays the current hostname.
hostname-f displays the FQDN.
hostname -fSet 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/hostnameEdit /etc/hosts:
vi /etc/hostsAppend:
<Global IP> [FQDN] <hostname>Verify
hostname
hostname -fhostname 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

