Hostname
The hostname
command displays or temporarily modifies the system's fully qualified hostname.
Specify a static hostname in the /etc/hostname
file. Use the hostnamectl
command to modify this file and may be used to view the status of the system's fully qualified hostname.
The conversion of hostnames to IP addresses or the reverse is determined by the configuration of the /etc/nsswitch.conf
file. By default, the contents of the /etc/hosts
file is checked first.
If an entry isn't found in the /etc/hosts
file, the stub resolver tries to look up the hostname by using a DNS nameserver. /etc/resolv.conf
file controls how this query is performed.
To test name resolution:
Summary
The system's static hostname is stored in the /etc/hostname
file. Use the hostnamectl
command to modify or view the status of the system's hostname and related settings. The hostname
command displays or temporarily modifies the system's hostname.
Command References:
nmcli
, hostnamectl
, hosts
, getent
, host
, nsswitch.conf
and resolv.conf
.