HOSTNAME(1)

NAME
hostname - set or print the name of current host system

SYNOPSIS
hostname [-s | -d] [name-of-host]

DESCRIPTION
The hostname utility prints the name of the current host. The super-user can set the hostname by supplying an argument; this is usually done in the initialization script /etc/rc.d/hostname, normally run at boot time. This script uses the hostname variable in /etc/rc.conf.

Options:

-s  Print only the hostname label before the first ‘’. in the Linux UTS hostname.

-d  Print only the suffix after the first ‘’. in the Linux UTS hostname. If no suffix exists, an empty line is printed.

This Linux port reads the hostname from uname(2) and writes it with sethostname(2). The -f flag is intentionally unsupported because a canonical FQDN requires NSS/DNS resolution policy outside the kernel hostname state.

EXAMPLES
Set the host name of the machine and check the result:

    $ hostname beastie.localdomain.org
    $ hostname
    beastie.localdomain.org

Show only the host label:

    $ hostname -s
    beastie

Show only domain information:

    $ hostname -d
    localdomain.org

SEE ALSO
sethostname(2), uname(2), rc.conf(5)

HISTORY
The hostname command appeared in 4.2BSD.