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

DESCRIPTION

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

OPTIONS

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

NOTES

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

FILES

176       /etc/hosts
177
178       /etc/sysconfig/network
179

AUTHORS

181       Peter Tobias, <tobias@et-inf.fho-emden.de>
182       Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
183       Michael Meskes, <meskes@debian.org>
184
185
186
187net-tools                         2009-09-16                       HOSTNAME(1)
Impressum