Header Ads Widget

[MAN] hostname

Content-type: text/html; charset=UTF-8 Man page of HOSTNAME

HOSTNAME

Section: Linux Programmer's Manual (1)
Updated: 2009-09-16
Index Return to Main Contents

 

NAME

hostname - show or set the system's host name
domainname - show or set the system's NIS/YP domain name
ypdomainname - show or set the system's NIS/YP domain name
nisdomainname - show or set the system's NIS/YP domain name
dnsdomainname - show the system's DNS domain name

 

SYNOPSIS

hostname [-a|--alias] [-d|--domain] [-f|--fqdn|--long] [-A|--all-fqdns] [-i|--ip-address] [-I|--all-ip-addresses] [-s|--short] [-y|--yp|--nis]
hostname [-b|--boot] [-F|--file filename] [hostname]
hostname [-h|--help] [-V|--version]

domainname [nisdomain] [-F file]
ypdomainname [nisdomain] [-F file]
nisdomainname [nisdomain] [-F file]

dnsdomainname

 

DESCRIPTION

Hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name.

 

GET NAME

When called without any arguments, the program displays the current names:

hostname will print the name of the system as returned by the gethostname(2) function.

domainname will print the NIS domainname of the system. domainname uses the gethostname(2) function, while ypdomainname and nisdomainname use the getdomainname(2).

dnsdomainname will print the domain part of the FQDN (Fully Qualified Domain Name). The complete FQDN of the system is returned with hostname --fqdn (but see the warnings in section THE FQDN below).

 

SET NAME

When called with one argument or with the --file option, the commands set the host name or the NIS/YP domain name. hostname uses the sethostname(2) function, while all of the three domainname, ypdomainname and nisdomainname use setdomainname(2). Note, that this is effective only until the next reboot. Edit /etc/hostname for permanent change.

Note, that only the super-user can change the names.

It is not possible to set the FQDN or the DNS domain name with the dnsdomainname command (see THE FQDN below).

The host name is usually set once at system startup in /etc/init.d/hostname.sh (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).

 

THE FQDN

The FQDN (Fully Qualified Domain Name) of the system is the name that the resolver(3) returns for the host name, such as, ursula.example.com. It is usually the hostname followed by the DNS domain name (the part after the first dot). You can check the FQDN using hostname --fqdn or the domain name using dnsdomainname.

You cannot change the FQDN with hostname or dnsdomainname.

The recommended method of setting the FQDN is to make the hostname be an alias for the fully qualified name using /etc/hosts, DNS, or NIS. For example, if the hostname was "ursula", one might have a line in /etc/hosts which reads

127.0.1.1 ursula.example.com ursula

Technically: The FQDN is the name getaddrinfo(3) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.

Therefore it depends on the configuration of the resolver (usually in /etc/host.conf) 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 /etc/hosts.

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 hostname --fqdn, hostname --domain and dnsdomainname. hostname --ip-address is subject to the same limitations so it should be avoided as well.

 

OPTIONS

-a, --alias
Display the alias name of the host (if used). This option is deprecated and should not be used anymore.
-A, --all-fqdns
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.
-b, --boot
Always set a hostname; this allows the file specified by -F to be non-existant or empty, in which case the default hostname localhost will be used if none is yet set.
-d, --domain
Display the name of the DNS domain. Don't use the command domainname to get the DNS domain name because it will show the NIS domain name and not the DNS domain name. Use dnsdomainname instead. See the warnings in section THE FQDN above, and avoid using this option.
-f, --fqdn, --long
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 /etc/hosts file. See the warnings in section THE FQDN above und use hostname --all-fqdns instead wherever possible.
-F, --file filename
Read the host name from the specified file. Comments (lines starting with a `#') are ignored.
-i, --ip-address
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 hostname --all-ip-addresses instead.
-I, --all-ip-addresses
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, this option does not depend on name resolution. Do not make any assumptions about the order of the output.
-s, --short
Display the short host name. This is the host name cut at the first dot.
-V, --version
Print version information on standard output and exit successfully.
-y, --yp, --nis
Display the NIS domain name. If a parameter is given (or --file name ) then root can also set a new NIS domain.
-h, --help
Print a usage message and exit.
 

NOTES

The address families hostname 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 inet6 option in /etc/resolv.conf.  

FILES

/etc/hostname 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.

/etc/hosts Usually, this is where one sets the domain name by aliasing the host name to the FQDN.  

AUTHORS

Peter Tobias, <tobias@et-inf.fho-emden.de>
Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
Michael Meskes, <meskes@debian.org>


 

Index

NAME
SYNOPSIS
DESCRIPTION
GET NAME
SET NAME
THE FQDN
OPTIONS
NOTES
FILES
AUTHORS

This document was created by man2html, using the manual pages.
Time: 04:45:31 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of HOSTNAME

HOSTNAME

Section: hostname (5)
Updated:
Index Return to Main Contents
 

NAME

hostname - Local hostname configuration file  

SYNOPSIS

/etc/hostname  

DESCRIPTION

The /etc/hostname file configures the name of the local system that is set during boot using the sethostname(2) system call. It should contain a single newline-terminated hostname string. Comments (lines starting with a `#') are ignored. The hostname may be a free-form string up to 64 characters in length; however, it is recommended that it consists only of 7-bit ASCII lower-case characters and no spaces or dots, and limits itself to the format allowed for DNS domain name labels, even though this is not a strict requirement.

You may use hostnamectl(1) to change the value of this file during runtime from the command line. Use systemd-firstboot(1) to initialize it on mounted (but not booted) system images.  

HISTORY

The simple configuration file format of /etc/hostname originates from Debian GNU/Linux.  

SEE ALSO

systemd(1), sethostname(2), hostname(1), hostname(7), machine-id(5), machine-info(5), hostnamectl(1), systemd-hostnamed.service(8), systemd-firstboot(1)


 

Index

NAME
SYNOPSIS
DESCRIPTION
HISTORY
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 04:45:54 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of HOSTNAME

HOSTNAME

Section: Linux Programmer's Manual (7)
Updated: 2017-05-03
Index Return to Main Contents
 

NAME

hostname - hostname resolution description  

DESCRIPTION

Hostnames are domains, where a domain is a hierarchical, dot-separated list of subdomains; for example, the machine "monet", in the "example" subdomain of the "com" domain would be represented as "monet.example.com".

Each element of the hostname must be from 1 to 63 characters long and the entire hostname, including the dots, can be at most 253 characters long. Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, and the hyphen (-). A hostname may not start with a hyphen.

Hostnames are often used with network client and server programs, which must generally translate the name to an address for use. (This task is generally performed by either getaddrinfo(3) or the obsolete gethostbyname(3).) Hostnames are resolved by the Internet name resolver in the following fashion.

If the name consists of a single component, that is, contains no dot, and if the environment variable HOSTALIASES is set to the name of a file, that file is searched for any string matching the input hostname. The file should consist of lines made up of two white-space separated strings, the first of which is the hostname alias, and the second of which is the complete hostname to be substituted for that alias. If a case-insensitive match is found between the hostname to be resolved and the first field of a line in the file, the substituted name is looked up with no further processing.

If the input name ends with a trailing dot, the trailing dot is removed, and the remaining name is looked up with no further processing.

If the input name does not end with a trailing dot, it is looked up by searching through a list of domains until a match is found. The default search list includes first the local domain, then its parent domains with at least 2 name components (longest first). For example, in the domain cs.example.com, the name lithium.cchem will be checked first as lithium.cchem.cs.example and then as lithium.cchem.example.com. lithium.cchem.com will not be tried, as there is only one component remaining from the local domain. The search path can be changed from the default by a system-wide configuration file (see resolver(5)).  

SEE ALSO

getaddrinfo(3), gethostbyname(3), resolver(5), mailaddr(7), named(8)

IETF RFC 1123

IETF RFC 1178  

COLOPHON

This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.


 

Index

NAME
DESCRIPTION
SEE ALSO
COLOPHON

This document was created by man2html, using the manual pages.
Time: 04:45:57 GMT, September 16, 2022

댓글 쓰기

0 댓글