hostname 中文man頁面
NAME(名稱)
hostname - 顯示或設(shè)置系統(tǒng)的主機名
domainname - 顯示或設(shè)置系統(tǒng)的NIS/YP域名
dnsdomainname - 顯示系統(tǒng)的DNS域名
nisdomainname - 顯示或設(shè)置系統(tǒng)的NIS/YP域名
ypdomainname - 顯示或設(shè)置系統(tǒng)的NIS/YP域名
nodename - 顯示或設(shè)置系統(tǒng)的DECnet節(jié)點名
SYNOPSIS(總覽)
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-address] [--long] [-s] [--short] [-y] [--yp] [--nis] [-n] [--node]
hostname [-v] [-F filename] [--file filename] [hostname]
domainname [-v] [-F filename] [--file filename] [name]
nodename [-v] [-F filename] [--file filename] [name]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
nisdomainname [-v]
ypdomainname [-v]
DESCRIPTION(描述)
Hostname 是一個用來設(shè)置或顯示當(dāng)前主機,域或者系統(tǒng)的節(jié)點名的程序.許多聯(lián)網(wǎng)程序使用這些名字來標(biāo)識機器.NIS/YP同樣也使用域名.
GET NAME(獲取名字)
如果不調(diào)用任何參數(shù),程序即顯示當(dāng)前的名字:
hostname 會打印系統(tǒng)的名字為通過 gethostname(2) 函數(shù)返回的值.
domainname,nisdomainname,ypdomainname 會打印系統(tǒng)的名字為通過 getdomainname(2) 函數(shù)返回的值.這同時也被看作系統(tǒng)的YP/NIS域名.
nodename 會打印系統(tǒng)的DECnet節(jié)點名為通過 getnodename(2) 函數(shù)返回的值.
dnsdomainname 會打印FQDN(完全資格域名)的域部分.系統(tǒng)的完整的FQDN可使用 hostname --fqdn 返回.
SET NAME(設(shè)置名字)
如果帶一個參數(shù)或者帶 --file 選項調(diào)用的話,命令即設(shè)置主機名,NIS/YP域名或者節(jié)點名.
注意,只有超級用戶才可以修改這些名字.
不可能使用 dnsdomainname 命令(參看下面的 THE FQDN ) 來設(shè)置FQDN或者DNS域名.
每次系統(tǒng)啟動時,主機名通常在 /etc/rc.d/rc.inet1 或 /etc/init.d/boot (一般通過讀取文件的內(nèi)容,其中包括了主機名,例如, /etc/hostname )中設(shè)置.
THE FQDN
你不能使用該命令修改FQDN(通過 hostname --fqdn 返回) 或者DNS域名(通過 dnsdomainname 返回).系統(tǒng)的FQDN是一個由 resolver(3) 返回的主機名.
從技術(shù)上說:FQDN指的是使用 gethostbyname(2) 以返回 gethostname (2) 所返回主機名的名字. DNS域名是***個圓點之后的部分.
因此它依賴于你修改方式的配置(通常在 /etc/host.conf 中).通常(如果hosts文件在DNS或NIS之前解析)你可以在 /etc/hosts 中修改.
OPTIONS(選項)
- -a,--alias
- 顯示主機的別名(如果使用了的話).
- -d,--domain
- 顯示DNS域名.不要使用命令 domainname 來獲得DNS域名,因為這會顯示NIS域名而非DNS域名.可使用 dnsdomainname 替換之.
- -F,--file filename
- 從指定文件中讀取主機名.注釋(以一個`#'開頭的行)可忽略.
- -f,--fqdn,--long
- 顯示FQDN(完全資格域名).一個FQDN包括一個短格式主機名和DNS域名.除非你正在使用bind或者NIS來作主機查詢,否則你可以在/etc/hosts文件中修改FQDN和DNS域名(這是FQDN的一部分).
- -h,--help
- 打印用法信息并退出.
- -i,--ip-address
- 顯示主機的IP地址(組).
- -n,--node
- 顯示DECnet節(jié)點名.如果指定了參數(shù)(或者指定了 --file name ),那么root也可以設(shè)置一個新的節(jié)點名.
- -s,--short
- 顯示短格式主機名.這是一個去掉***個圓點后面部分的主機名.
- -V,--version
- 在標(biāo)準(zhǔn)輸出上打印版本信息并以成功的狀態(tài)退出.
- -v,--verbose
- 詳盡說明并告知所正在執(zhí)行的.
- -y,--yp,--nis
- 顯示NIS域名.如果指定了參數(shù)(或者指定了 --file name ),那么root也可以設(shè)置一個新的NIS域.
FILES(相關(guān)文件)
/etc/hosts
AUTHOR(作者)
Peter Tobias, <tobias@et-inf.fho-emden.de>
ernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
Steve Whitehouse, <SteveW@ACM.org> (DECnet support and manpage).
#p#
NAME
hostname - show or set the system's host name
domainname - show or set the system's NIS/YP domain name
dnsdomainname - show the system's DNS domain name
nisdomainname - show or set system's NIS/YP domain name
ypdomainname - show or set the system's NIS/YP domain name
SYNOPSIS
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-address] [--long] [-s] [--short] [-y] [--yp] [--nis] [-n] [--node]
hostname [-v] [-F filename] [--file filename] [hostname]
domainname [-v] [-F filename] [--file filename] [name]
nodename [-v] [-F filename] [--file filename] [name]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
nisdomainname [-v]
ypdomainname [-v]
DESCRIPTION
Hostname is the program that is used to either set or display the current host, domain or node name of the system. These names are used by many of the networking programs to identify the machine. The domain name is also used by NIS/YP.
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, nisdomainname, ypdomainname will print the name of the system as returned by the getdomainname(2) function. This is also known as the YP/NIS domain name of the system.
dnsdomainname will print the domain part of the FQDN (Fully Qualified Domain Name). The complete FQDN of the system is returned with hostname --fqdn.
SET NAME
When called with one argument or with the --file option, the commands set the host name, the NIS/YP domain name or the node name.
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/rc.d/rc.inet1 or /etc/init.d/boot (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).
THE FQDN
You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name.
Technically: The FQDN is the name gethostbyname(2) 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 (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.
OPTIONS
- -a, --alias
- Display the alias name of the host (if used).
- -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.
- -F, --file filename
- Read the host name from the specified file. Comments (lines starting with a `#') are ignored.
- -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.
- -h, --help
- Print a usage message and exit.
- -i, --ip-address
- Display the IP address(es) of the host.
- -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.
- -v, --verbose
- Be verbose and tell what's going on.
- -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.
FILES
/etc/hosts
AUTHOR
Peter Tobias, <tobias@et-inf.fho-emden.de>
Bernd Eckenfels, <net-tools@lina.inka.de> (NIS and manpage).
Steve Whitehouse, <SteveW@ACM.org> (DECnet support and manpage).