linux操作系统下 domainname 命令介绍和使用案例
domainname 命令介绍
domainname
是一个用于显示或设置系统的 NIS(Network Information Service)域名的命令。它通常用于在网络中标识主机的域名。
功能
- 显示 NIS 域名:当不带参数使用时,
domainname
会返回当前系统的 NIS 域名。 - 设置 NIS 域名:可以通过提供参数来设置系统的 NIS 域名。
命令介绍
root@doris23:/data# domainname
meng.com
root@doris23:/data# domainname --help
Usage: hostname [-b] {hostname|-F file} set host name (from file)
hostname [-a|-A|-d|-f|-i|-I|-s|-y] display formatted name
hostname display host name
{yp,nis,}domainname {nisdomain|-F file} set NIS domain name (from file)
{yp,nis,}domainname display NIS domain name
dnsdomainname display dns domain name
hostname -V|--version|-h|--help print info and exit
Program name:
{yp,nis,}domainname=hostname -y
dnsdomainname=hostname -d
Program options:
-a, --alias alias names
-A, --all-fqdns all long host names (FQDNs)
-b, --boot set default hostname if none available
-d, --domain DNS domain name
-f, --fqdn, --long long host name (FQDN)
-F, --file read host name or NIS domain name from given file
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
-s, --short short host name
-y, --yp, --nis NIS/YP domain name
Description:
This command can get or set the host name or the NIS domain name. You can
also get the DNS domain or the FQDN (fully qualified domain name).
Unless you are using bind or NIS for host lookups you can change the
FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
part of the FQDN) in the /etc/hosts file.
命令案例
root@doris23:/data# domainname
(none)
root@doris23:/data# domainname meng.com
root@doris23:/data# domainname
meng.com
root@doris23:/data# hostname
doris23
root@doris23:/data# hostname && domainname
doris23
meng.com