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] [-i] [--ip-
15       address] [--long] [-s] [--short] [-y] [--yp] [--nis]
16
17
18       hostname [-v] [-F filename] [--file filename] [hostname]
19
20
21       domainname [-v] [-F filename] [--file filename] [name]
22
23
24       nodename [-v] [-F filename] [--file filename] [name]
25
26
27       hostname [-v] [-h] [--help] [-V] [--version]
28
29
30       dnsdomainname [-v]
31       nisdomainname [-v]
32       ypdomainname [-v]
33
34

DESCRIPTION

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

OPTIONS

105       -a, --alias
106              Display the alias name of the host (if used).
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.
113
114       -F, --file filename
115              Read  the  host  name  from  the specified file. Comments (lines
116              starting with a `#') are ignored.
117
118       -f, --fqdn, --long
119              Display the FQDN (Fully Qualified Domain Name). A FQDN  consists
120              of  a  short  host  name and the DNS domain name. Unless you are
121              using bind or NIS for host lookups you can change the  FQDN  and
122              the  DNS  domain  name  (which  is  part  of  the  FQDN)  in the
123              /etc/hosts file.
124
125       -h, --help
126              Print a usage message and exit.
127
128       -i, --ip-address
129              Display the IP address(es) of the host.
130
131       -s, --short
132              Display the short host name. This is the host name  cut  at  the
133              first dot.
134
135       -V, --version
136              Print  version  information on standard output and exit success‐
137              fully.
138
139       -v, --verbose
140              Be verbose and tell what's going on.
141
142       -y, --yp, --nis
143              Display the NIS domain name. If a parameter is given (or  --file
144              name ) then root can also set a new NIS domain.
145

FILES

147       /etc/hosts /etc/sysconfig/network
148

NOTE

150       Note  that  hostname  doesn't change anything permanently. After reboot
151       original names from /etc/hosts are used again.
152

AUTHOR

154       Peter Tobias, <tobias@et-inf.fho-emden.de>
155       Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
156       Steve Whitehouse, <SteveW@ACM.org> (DECnet support and manpage).
157
158
159
160
161net-tools                         28 Jan 1996                      HOSTNAME(1)
Impressum