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       dnsdomainname - show the system's DNS domain name
9       nisdomainname - show or set system's NIS/YP domain name
10       ypdomainname - show or set the system's NIS/YP 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
18
19       hostname [-v] [-F filename] [--file filename] [hostname]
20
21
22       domainname [-v] [-F filename] [--file filename] [name]
23
24
25       nodename [-v] [-F filename] [--file filename] [name]
26
27
28       hostname [-v] [-h] [--help] [-V] [--version]
29
30
31       dnsdomainname [-v]
32       nisdomainname [-v]
33       ypdomainname [-v]
34
35

DESCRIPTION

37       Hostname  is the program that is used to either set or display the cur‐
38       rent host, domain or node name of the system.  These names are used  by
39       many  of  the  networking  programs to identify the machine. The domain
40       name is also used by NIS/YP.
41
42
43   GET NAME
44       When called without any arguments, the  program  displays  the  current
45       names:
46
47
48       hostname  will print the name of the system as returned by the gethost‐
49       name(2) function.
50
51
52       domainname, nisdomainname, ypdomainname will print the name of the sys‐
53       tem as returned by the getdomainname(2) function. This is also known as
54       the YP/NIS domain name of the system.
55
56
57       dnsdomainname will print the domain part of the FQDN  (Fully  Qualified
58       Domain Name). The complete FQDN of the system is returned with hostname
59       --fqdn.
60
61
62       The function gethostname(2) is used to  get  the  hostname.   When  the
63       hostname  -a,  -d,  -f or -i is called will gethostbyname(3) be called.
64       The difference in gethostname(2) and gethostbyname(3) is that  gethost‐
65       byname(3)  is  network  aware,  so  it  consults /etc/nsswitch.conf and
66       /etc/host.conf to decide whether to read  information  in  /etc/syscon‐
67       fig/network or /etc/hosts
68
69       To  add  another  dimension  to this, the hostname is also set when the
70       network interface is brought up.
71
72
73   SET NAME
74       When called with one argument or with the --file option,  the  commands
75       set the host name, the NIS/YP domain name or the node name.
76
77
78       Note, that only the super-user can change the names.
79
80
81       It is not possible to set the FQDN or the DNS domain name with the dns‐
82       domainname command (see THE FQDN below).
83
84
85       The  host  name  is   usually   set   once   at   system   startup   in
86       /etc/rc.d/rc.inet1  or  /etc/init.d/boot  (normally by reading the con‐
87       tents of a file which contains the host name, e.g.  /etc/hostname).
88
89
90   THE FQDN
91       You can't change the FQDN (as returned by hostname --fqdn) or  the  DNS
92       domain  name (as returned by dnsdomainname) with this command. The FQDN
93       of the system is the name that the resolver(3)  returns  for  the  host
94       name.
95
96
97       Technically: The FQDN is the name gethostbyname(2) returns for the host
98       name returned by gethostname(2).  The DNS domain name is the part after
99       the first dot.
100
101       Therefore  it  depends on the configuration (usually in /etc/host.conf)
102       how you can change it. Usually (if the hosts file is parsed before  DNS
103       or NIS) you can change it in /etc/hosts.
104
105       If  a machine has multiple network interfaces/addresses or is used in a
106       mobile environment, then it may either have multiple FQDNs/domain names
107       or  none  at  all.  Therefore  avoid  using  hostname  --fqdn, hostname
108       --domain and dnsdomainname.  hostname --ip-address is  subject  to  the
109       same limitations so it should be avoided as well.
110
111

OPTIONS

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

FILES

176       /etc/hosts /etc/sysconfig/network
177

NOTE

179       Note  that  hostname  doesn't change anything permanently. After reboot
180       original names from /etc/hosts are used again.
181

AUTHOR

183       Peter Tobias, <tobias@et-inf.fho-emden.de>
184       Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
185       Steve Whitehouse, <SteveW@ACM.org> (DECnet support and manpage).
186
187
188
189
190net-tools                         28 Jan 1996                      HOSTNAME(1)
Impressum