431 lines
9.4 KiB
HTML
431 lines
9.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of HOSTNAME</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>HOSTNAME</H1>
|
|
Section: Linux Programmer's Manual (1)<BR>Updated: 2009-09-16<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<P>
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
hostname - show or set the system's host name
|
|
<BR>
|
|
|
|
domainname - show or set the system's NIS/YP domain name
|
|
<BR>
|
|
|
|
ypdomainname - show or set the system's NIS/YP domain name
|
|
<BR>
|
|
|
|
nisdomainname - show or set the system's NIS/YP domain name
|
|
<BR>
|
|
|
|
dnsdomainname - show the system's DNS domain name
|
|
<BR>
|
|
|
|
<P>
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>hostname</B>
|
|
|
|
[<B>-a|--alias</B>]
|
|
|
|
[<B>-d|--domain</B>]
|
|
|
|
[<B>-f|--fqdn|--long</B>]
|
|
|
|
[<B>-A|--all-fqdns</B>]
|
|
|
|
[<B>-i|--ip-address</B>]
|
|
|
|
[<B>-I|--all-ip-addresses</B>]
|
|
|
|
[<B>-s|--short</B>]
|
|
|
|
[<B>-y|--yp|--nis</B>]
|
|
|
|
<BR>
|
|
|
|
<B>hostname</B>
|
|
|
|
[<B>-b|--boot</B>]
|
|
|
|
[<B>-F|--file filename</B>]
|
|
|
|
[<B>hostname</B>]
|
|
|
|
<BR>
|
|
|
|
<B>hostname</B>
|
|
|
|
[<B>-h|--help</B>]
|
|
|
|
[<B>-V|--version</B>]
|
|
|
|
<P>
|
|
|
|
<B>domainname</B>
|
|
|
|
[<B>nisdomain</B>]
|
|
|
|
[<B>-F file</B>]
|
|
|
|
<BR>
|
|
|
|
<B>ypdomainname</B>
|
|
|
|
[<B>nisdomain</B>]
|
|
|
|
[<B>-F file</B>]
|
|
|
|
<BR>
|
|
|
|
<B>nisdomainname</B>
|
|
|
|
[<B>nisdomain</B>]
|
|
|
|
[<B>-F file</B>]
|
|
|
|
<P>
|
|
|
|
<B>dnsdomainname</B>
|
|
|
|
<P>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>Hostname</B>
|
|
|
|
is used to display the system's DNS name, and to display or set its hostname or
|
|
NIS domain name.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H3>GET NAME</H3>
|
|
|
|
When called without any arguments, the program displays the current
|
|
names:
|
|
<P>
|
|
|
|
<B>hostname</B>
|
|
|
|
will print the name of the system as returned by the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+gethostname">gethostname</A></B>(2)
|
|
|
|
function.
|
|
<P>
|
|
|
|
<B>domainname</B>
|
|
|
|
will print the NIS domainname of the system.
|
|
<B>domainname</B>
|
|
|
|
uses the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+gethostname">gethostname</A></B>(2)
|
|
|
|
function, while
|
|
<B>ypdomainname</B>
|
|
|
|
and
|
|
<B>nisdomainname</B>
|
|
|
|
use the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getdomainname">getdomainname</A></B>(2).
|
|
|
|
<P>
|
|
|
|
<B>dnsdomainname</B>
|
|
|
|
will print the domain part of the FQDN (Fully Qualified Domain Name). The
|
|
complete FQDN of the system is returned with
|
|
<B>hostname --fqdn</B>
|
|
|
|
(but see the warnings in section
|
|
<B>THE FQDN</B>
|
|
|
|
below).
|
|
<P>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>SET NAME</H3>
|
|
|
|
When called with one argument or with the
|
|
<B>--file</B>
|
|
|
|
option, the commands set the host name or the NIS/YP domain name.
|
|
<B>hostname</B>
|
|
|
|
uses the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sethostname">sethostname</A></B>(2)
|
|
|
|
function, while all of the three
|
|
<B>domainname</B>,
|
|
|
|
<B>ypdomainname</B>
|
|
|
|
and
|
|
<B>nisdomainname</B>
|
|
|
|
use
|
|
<B><A HREF="/cgi-bin/man/man2html?2+setdomainname">setdomainname</A></B>(2).
|
|
|
|
Note, that this is effective only until the next reboot.
|
|
Edit /etc/hostname for permanent change.
|
|
<P>
|
|
|
|
Note, that only the super-user can change the names.
|
|
<P>
|
|
|
|
It is not possible to set the FQDN or the DNS domain name with the
|
|
<B>dnsdomainname</B>
|
|
|
|
command (see
|
|
<B>THE FQDN</B>
|
|
|
|
below).
|
|
<P>
|
|
|
|
The host name is usually set once at system startup in
|
|
<I>/etc/init.d/hostname.sh</I>
|
|
|
|
(normally by reading the contents of a file which contains
|
|
the host name, e.g.
|
|
<I>/etc/hostname</I>).
|
|
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>THE FQDN</H3>
|
|
|
|
The FQDN (Fully Qualified Domain Name) of the system is the name that the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+resolver">resolver</A></B>(3)
|
|
|
|
returns for the host name, such as,
|
|
<I>ursula.example.com</I>.
|
|
|
|
It is usually the hostname followed by the DNS domain name (the part
|
|
after the first dot). You can check the FQDN using
|
|
<B>hostname --fqdn</B>
|
|
|
|
or the domain name using
|
|
<B>dnsdomainname</B>.
|
|
|
|
<P>
|
|
|
|
You cannot change the FQDN with
|
|
<B>hostname</B>
|
|
|
|
or
|
|
<B>dnsdomainname</B>.
|
|
|
|
<P>
|
|
|
|
The recommended method of setting the FQDN is to make the hostname be
|
|
an alias for the fully qualified name using
|
|
<I>/etc/hosts</I>,
|
|
|
|
DNS, or NIS. For example, if the hostname was "ursula", one might have a line in
|
|
<I>/etc/hosts</I>
|
|
|
|
which reads
|
|
<P>
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
127.0.1.1 ursula.example.com ursula
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
Technically: The FQDN is the name
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getaddrinfo">getaddrinfo</A></B>(3)
|
|
|
|
returns for the host name returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?2+gethostname">gethostname</A></B>(2).
|
|
|
|
The DNS domain name is the part after the first dot.
|
|
<P>
|
|
|
|
Therefore it depends on the configuration of the resolver (usually in
|
|
<I>/etc/host.conf</I>)
|
|
|
|
how you can change it. Usually the hosts file is parsed before DNS or
|
|
NIS, so it is most common to change the FQDN in
|
|
<I>/etc/hosts</I>.
|
|
|
|
<P>
|
|
|
|
If a machine has multiple network interfaces/addresses or is used in a
|
|
mobile environment, then it may either have multiple FQDNs/domain names
|
|
or none at all. Therefore avoid using
|
|
<B>hostname --fqdn</B>,
|
|
|
|
<B>hostname --domain</B>
|
|
|
|
and
|
|
<B>dnsdomainname</B>.
|
|
|
|
<B>hostname --ip-address</B>
|
|
|
|
is subject to the same limitations so it should be avoided as well.
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="2"><I>-a, --alias</I>
|
|
|
|
<DD>
|
|
Display the alias name of the host (if used). This option is deprecated
|
|
and should not be used anymore.
|
|
<DT id="3"><I>-A, --all-fqdns</I>
|
|
|
|
<DD>
|
|
Displays all FQDNs of the machine. This option enumerates all configured
|
|
network addresses on all configured network interfaces, and translates
|
|
them to DNS domain names. Addresses that cannot be translated (i.e. because
|
|
they do not have an appropriate reverse IP entry) are skipped. Note that
|
|
different addresses may resolve to the same name, therefore the output may
|
|
contain duplicate entries. Do not make any assumptions about the order of the
|
|
output.
|
|
<DT id="4"><I>-b, --boot</I>
|
|
|
|
<DD>
|
|
Always set a hostname; this allows the file specified by <I>-F</I> to be
|
|
non-existent or empty, in which case the default hostname <I>localhost</I>
|
|
will be used if none is yet set.
|
|
<DT id="5"><I>-d, --domain</I>
|
|
|
|
<DD>
|
|
Display the name of the DNS domain. Don't use the command
|
|
<B>domainname</B>
|
|
|
|
to get the DNS domain name because it will show the NIS domain name and
|
|
not the DNS domain name. Use
|
|
<B>dnsdomainname</B>
|
|
|
|
instead. See the warnings in section
|
|
<B>THE FQDN</B>
|
|
|
|
above, and avoid using this option.
|
|
<DT id="6"><I>-f, --fqdn, --long</I>
|
|
|
|
<DD>
|
|
Display the FQDN (Fully Qualified Domain Name). A FQDN consists of a
|
|
short host name and the DNS domain name. Unless you are using bind or NIS
|
|
for host lookups you can change the FQDN and the DNS domain name (which is
|
|
part of the FQDN) in the <I>/etc/hosts</I> file. See the warnings in section
|
|
<B>THE FQDN</B>
|
|
|
|
above und use
|
|
<B>hostname --all-fqdns</B>
|
|
|
|
instead wherever possible.
|
|
<DT id="7"><I>-F, --file filename</I>
|
|
|
|
<DD>
|
|
Read the host name from the specified file. Comments (lines starting with
|
|
a `#') are ignored.
|
|
<DT id="8"><I>-i, --ip-address</I>
|
|
|
|
<DD>
|
|
Display the network address(es) of the host name. Note that this works only
|
|
if the host name can be resolved. Avoid using this option; use
|
|
<B>hostname --all-ip-addresses</B>
|
|
|
|
instead.
|
|
<DT id="9"><I>-I, --all-ip-addresses</I>
|
|
|
|
<DD>
|
|
Display all network addresses of the host. This option enumerates all
|
|
configured addresses on all network interfaces. The loopback interface and IPv6
|
|
link-local addresses are omitted. Contrary to option <I>-i</I>, this option
|
|
does not depend on name resolution. Do not make any assumptions about the
|
|
order of the output.
|
|
<DT id="10"><I>-s, --short</I>
|
|
|
|
<DD>
|
|
Display the short host name. This is the host name cut at the first dot.
|
|
<DT id="11"><I>-V, --version</I>
|
|
|
|
<DD>
|
|
Print version information on standard output and exit successfully.
|
|
<DT id="12"><I>-y, --yp, --nis</I>
|
|
|
|
<DD>
|
|
Display the NIS domain name. If a parameter is given (or
|
|
<B>--file name</B>
|
|
|
|
) then root can also set a new NIS domain.
|
|
<DT id="13"><I>-h, --help</I>
|
|
|
|
<DD>
|
|
Print a usage message and exit.
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The address families
|
|
<B>hostname</B>
|
|
|
|
tries when looking up the FQDN, aliases and network addresses of the
|
|
host are determined by the configuration of your resolver.
|
|
For instance, on GNU Libc systems, the resolver can be instructed to
|
|
try IPv6 lookups first by using the
|
|
<B>inet6</B>
|
|
|
|
option in
|
|
<B>/etc/resolv.conf</B>.
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<B>/etc/hostname</B>
|
|
|
|
Historically this file was supposed to only contain the hostname and not the
|
|
full canonical FQDN. Nowadays most software is able to cope with a full FQDN
|
|
here. This file is read at boot time by the system initialization scripts to
|
|
set the hostname.
|
|
<P>
|
|
|
|
<B>/etc/hosts</B>
|
|
|
|
Usually, this is where one sets the domain name by aliasing the host name to
|
|
the FQDN.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>AUTHORS</H2>
|
|
|
|
Peter Tobias, <<A HREF="mailto:tobias@et-inf.fho-emden.de">tobias@et-inf.fho-emden.de</A>>
|
|
<BR>
|
|
|
|
Bernd Eckenfels, <<A HREF="mailto:net-tools@lina.inka.de">net-tools@lina.inka.de</A>> (NIS and manpage).
|
|
<BR>
|
|
|
|
Michael Meskes, <<A HREF="mailto:meskes@debian.org">meskes@debian.org</A>>
|
|
<BR>
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="14"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="15"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="16"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="17"><A HREF="#lbAE">GET NAME</A><DD>
|
|
<DT id="18"><A HREF="#lbAF">SET NAME</A><DD>
|
|
<DT id="19"><A HREF="#lbAG">THE FQDN</A><DD>
|
|
</DL>
|
|
<DT id="20"><A HREF="#lbAH">OPTIONS</A><DD>
|
|
<DT id="21"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="22"><A HREF="#lbAJ">FILES</A><DD>
|
|
<DT id="23"><A HREF="#lbAK">AUTHORS</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:16 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|