hostname - show or set the system's host name
dnsdomainname - show the system's domain name


hostname [ -d ] [ --domain ] [ -F filename ] [ --file filename ] [ -f ] [ --fqdn ] [ -h ] [ --help ] [ --long ] [ -s ] [ --short ] [ -v ] [ --version ] [ name ]


Hostname is the program that is used to either set the host name or display the current host or domain name of the system. This name is used by many of the networking programs to identify the machine.

When called without any arguments, the program displays the current name as set by the hostname command. You can change the output format to display always the short or the long host name (FQDN). When called with arguments, the program will set the value of the host name to the value specified. This usually is done only once, at system startup time, by the /etc/rc.d/rc.inet1 configuration script.

Note, that only the super-user can change the host name.

If the program was called as dnsdomainname it will show the DNS domain name. You can't change the DNS domain name with dnsdomainname (see below).


-d, --domain
Display the name of the DNS domain. Don't use the command domainname to get the DNS domain name because it will show the NIS domain name and not the DNS domain name.

-F, --file filename
Read the host name from the specified file. Comments (lines starting with a `#') are ignored.

-f, --fqdn, --long
Display the FQDN (Fully Qualified Domain Name). A FQDN consists of a short host name and the DNS domain name. Unless you are using bind or NIS for host lookups you can change the FQDN and the DNS domain name (which is part of the FQDN) in the /etc/hosts file.

-h, --help
Print a usage message on standard output and exit successfully.

-s, --short
Display the short host name.

-v, --version
Print version information on standard output and exit successfully.




Peter Tobias, <>