hostname

Display and set the system's hostname

Supplementary instructions

hostname command Used to display and set the host name of the system.

grammar

hostname [-b] {hostname|-F file} Set the hostname (or get it from a file)
hostname [-a|-A|-d|-f|-i|-I|-s|-y] displays the formatted name
hostname displays the host name

{yp,nis,}domainname {nisdomain|-F file} Set the NIS host name (or get it from a file)
{yp,nis,}domainname displays the NIS host name

dnsdomainname displays DNS host name

hostname -V|--version|-h|--help print information and exit

Options

-a, --alias display host aliases
-A, --all-fqdns display all FQDN names
-b, --boot Set default hostname if no hostname is available
-d, --domain Display DNS domain name
-f, --fqdn, --long display FQDN name
-F, --file Read hostname or NIS domain name from the given file
-i, --ip-address Display the ip address of the host
-I, --all-ip-addresses display all ip addresses of the host
-s, --short Display short hostname, truncated at first point
-y, --yp, --nis display NIS domain name

Example

show hostname

[root@AY1307311912260196fcZ ~]# hostname
AY1307311912260196fcZ

Temporarily change hostname

[root@AY1307311912260196fcZ ~]# hostname newname

Display all IP addresses of a host

[root@AY1307311912260196fcZ ~]# hostname -I
10.17.0.1 10.18.0.10 172.17.0.1