1HOSTNAME(1)                Linux Programmer's Manual               HOSTNAME(1)
2
3
4

NAME

6       hostname - show or set the system's host name
7       domainname - show or set the system's NIS/YP domain name
8       ypdomainname - show or set the system's NIS/YP domain name
9       nisdomainname - show or set the system's NIS/YP domain name
10       dnsdomainname - show the system's DNS domain name
11
12

SYNOPSIS

14       hostname [-a|--alias] [-d|--domain] [-f|--fqdn|--long] [-A|--all-fqdns]
15       [-i|--ip-address] [-I|--all-ip-addresses] [-s|--short] [-y|--yp|--nis]
16       hostname [-b|--boot] [-F|--file filename] [hostname]
17       hostname [-h|--help] [-V|--version]
18
19       domainname [nisdomain] [-F file]
20       ypdomainname [nisdomain] [-F file]
21       nisdomainname [nisdomain] [-F file]
22
23       dnsdomainname
24
25

DESCRIPTION

27       Hostname is used to display the system's DNS name, and  to  display  or
28       set its hostname or NIS domain name.
29
30
31   GET NAME
32       When  called  without  any  arguments, the program displays the current
33       names:
34
35       hostname will print the name of the system as returned by the  gethost‐
36       name(2) function.
37
38       domainname  will  print  the  NIS domainname of the system.  domainname
39       uses the gethostname(2) function, while ypdomainname and  nisdomainname
40       use the yp_get_default_domain(3).
41
42       dnsdomainname  will  print the domain part of the FQDN (Fully Qualified
43       Domain Name). The complete FQDN of the system is returned with hostname
44       --fqdn (but see the warnings in section THE FQDN below).
45
46
47       The  function  gethostname(2)  is  used  to get the hostname.  When the
48       hostname -a, -d, -f or -i is called will  gethostbyname(3)  be  called.
49       The  difference in gethostname(2) and gethostbyname(3) is that gethost‐
50       byname(3) is network  aware,  so  it  consults  /etc/nsswitch.conf  and
51       /etc/host.conf  to  decide whether to read information in /etc/hostname
52       or /etc/hosts
53
54
55   SET NAME
56       When called with one argument or with the --file option,  the  commands
57       set  the  host  name  or  the  NIS/YP  domain  name.  hostname uses the
58       sethostname(2) function, while all of the three  domainname,  ypdomain‐
59       name and nisdomainname use setdomainname(2).  Note, that this is effec‐
60       tive only until the next  reboot.   Edit  /etc/hostname  for  permanent
61       change.
62
63       Note, that only the super-user can change the names.
64
65       It is not possible to set the FQDN or the DNS domain name with the dns‐
66       domainname command (see THE FQDN below).
67
68       The host name is usually set once at system startup (normally by  read‐
69       ing  the  contents  of  a  file  which  contains  the  host  name, e.g.
70       /etc/hostname).
71
72
73   THE FQDN
74       The FQDN (Fully Qualified Domain Name) of the system is the  name  that
75       the resolver(3) returns for the host name, such as, ursula.example.com.
76       It is usually the hostname followed by the DNS domain  name  (the  part
77       after  the first dot).  You can check the FQDN using hostname --fqdn or
78       the domain name using dnsdomainname.
79
80       You cannot change the FQDN with hostname or dnsdomainname.
81
82       The recommended method of setting the FQDN is to make the  hostname  be
83       an  alias  for  the fully qualified name using /etc/hosts, DNS, or NIS.
84       For example, if the hostname was "ursula", one might  have  a  line  in
85       /etc/hosts which reads
86
87              127.0.1.1    ursula.example.com ursula
88
89       Technically:  The  FQDN is the name getaddrinfo(3) returns for the host
90       name returned by gethostname(2).  The DNS domain name is the part after
91       the first dot.
92
93       Therefore  it  depends on the configuration of the resolver (usually in
94       /etc/host.conf) how you can change it. Usually the hosts file is parsed
95       before  DNS  or  NIS,  so  it  is  most  common  to  change the FQDN in
96       /etc/hosts.
97
98       If a machine has multiple network interfaces/addresses or is used in  a
99       mobile environment, then it may either have multiple FQDNs/domain names
100       or none  at  all.  Therefore  avoid  using  hostname  --fqdn,  hostname
101       --domain  and  dnsdomainname.   hostname --ip-address is subject to the
102       same limitations so it should be avoided as well.
103
104

OPTIONS

106       -a, --alias
107              Display the alias name of the host (if  used).  This  option  is
108              deprecated and should not be used anymore.
109
110       -A, --all-fqdns
111              Displays  all  FQDNs  of the machine. This option enumerates all
112              configured network addresses on all  configured  network  inter‐
113              faces,  and  translates them to DNS domain names. Addresses that
114              cannot be translated (i.e. because they do not have an appropri‐
115              ate   reverse  DNS  entry)  are  skipped.  Note  that  different
116              addresses may resolve to the same name, therefore the output may
117              contain duplicate entries. Do not make any assumptions about the
118              order of the output.
119
120       -b, --boot
121              Always set a hostname; this allows the file specified by  -F  to
122              be  non-existant  or  empty,  in which case the default hostname
123              localhost will be used if none is yet set.
124
125       -d, --domain
126              Display the name of the  DNS  domain.   Don't  use  the  command
127              domainname  to  get the DNS domain name because it will show the
128              NIS domain name and not the DNS domain name.  Use  dnsdomainname
129              instead.  See  the warnings in section THE FQDN above, and avoid
130              using this option.
131
132       -f, --fqdn, --long
133              Display the FQDN (Fully Qualified Domain Name). A FQDN  consists
134              of  a  short  host  name and the DNS domain name. Unless you are
135              using bind or NIS for host lookups you can change the  FQDN  and
136              the  DNS  domain  name  (which  is  part  of  the  FQDN)  in the
137              /etc/hosts file. See the warnings in section THE FQDN above, and
138              avoid using this option; use hostname --all-fqdns instead.
139
140       -F, --file filename
141              Read  the  host  name  from  the specified file. Comments (lines
142              starting with a `#') are ignored.
143
144       -i, --ip-address
145              Display the network address(es) of the host name. Note that this
146              works  only  if  the host name can be resolved. Avoid using this
147              option; use hostname --all-ip-addresses instead.
148
149       -I, --all-ip-addresses
150              Display all network addresses of the host. This  option  enumer‐
151              ates  all  configured  addresses  on all network interfaces. The
152              loopback interface and IPv6 link-local  addresses  are  omitted.
153              Contrary to option -i, this option does not depend on name reso‐
154              lution. Do not make any assumptions about the order of the  out‐
155              put.
156
157       -s, --short
158              Display  the  short  host name. This is the host name cut at the
159              first dot.
160
161       -V, --version
162              Print version information on standard output and  exit  success‐
163              fully.
164
165       -y, --yp, --nis
166              Display  the NIS domain name. If a parameter is given (or --file
167              name ) then root can also set a new NIS domain.
168
169       -h, --help
170              Print a usage message and exit.
171

NOTES

173       The address families hostname tries when looking up the  FQDN,  aliases
174       and  network  addresses of the host are determined by the configuration
175       of your resolver.  For instance, on GNU Libc systems, the resolver  can
176       be  instructed  to  try IPv6 lookups first by using the inet6 option in
177       /etc/resolv.conf.
178

FILES

180       /etc/hostname Historically this file was supposed to only  contain  the
181       hostname  and  not  the  full canonical FQDN. Nowadays most software is
182       able to cope with a full FQDN here. This file is read at boot  time  by
183       the system initialization scripts to set the hostname.
184
185       /etc/hosts  Usually, this is where one sets the domain name by aliasing
186       the host name to the FQDN.
187

AUTHORS

189       Peter Tobias, <tobias@et-inf.fho-emden.de>
190       Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
191       Michael Meskes, <meskes@debian.org>
192
193
194
195net-tools                         2009-09-16                       HOSTNAME(1)
Impressum