Linux系统之hostname相关命令基本使用

Linux系统之hostname相关命令基本使用冬日生活打卡季 一 检查本地系统版本 root server 01 cat etc os release NAME CentOS Linux VERSION 8 Core I

大家好,欢迎来到IT知识分享网。

Linux系统之hostname相关命令基本使用

#冬日生活打卡季#

一、检查本地系统版本

[root@server-01 ~]# cat /etc/os-release NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8"

二、hostname在Linux的帮助说明

 [root@server-01 ~]# hostname --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.

三、hostname的中文帮助说明

 用法:hostname[-b]{hostname |-F file}设置主机名(来自文件) 主机名[-a|-a|-d|-f|-i|-i|-s|-y]显示格式化名称 主机名显示主机名 {yp,nis,}域名{nisdomain |-F文件}设置nis域名(来自文件) {yp,nis,}域名显示nis域名 dnsdomainname显示dns域名 主机名-V|--版本|-h|--帮助打印信息并退出 程序名称: {yp,nis,}域名=主机名-y dnsdomainname=主机名-d 程序选项: -a、 --别名别名 -A、 --所有fqdns所有长主机名(FQDN) -b、 --如果没有可用的主机名,则启动设置默认主机名 -d、 --域DNS域名 -f、 --fqdn,--长主机名(fqdn) -F、 --从给定文件读取主机名或NIS域名 -i、 --主机名的ip地址地址 -I、 --所有ip地址主机的所有地址 -s、 --短主机名 -y、 --yp,--nis nis/yp域名 描述: 此命令可以获取或设置主机名或NIS域名。你可以 还可以获取DNS域或FQDN(完全限定域名)。 除非您使用绑定或NIS进行主机查找,否则可以更改 FQDN(完全限定域名)和DNS域名( FQDN的一部分)。

四、hostname命令的基本使用

1.查看计算机名

[root@server-01 ~]# hostname server-01

2.查看本机上所有IP地址

[root@server-01 ~]# hostname -I 192.168.200.150 172.17.0.1 172.21.0.1 172.19.0.1 172.20.0.1

3.查看主机FQDN

[root@server-01 ~]# hostname -f server-01

4.查看短主机名

[root@server-01 ~]# hostname -s server-01

五、hostnamectl的使用

1.查看主机详细信息

[root@server-01 ~]# hostnamectl Static hostname: server-01 Icon name: computer-vm Chassis: vm Machine ID: 8daa9318db557c0bf5b06c3b8 Boot ID: f45c90c8ca254ef28bf4da5b04bdafdf Virtualization: kvm Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-240.10.1.el8_3.x86_64 Architecture: x86-64

2.设置主机名

[root@server-01 ~]# hostnamectl set-hostname test

3.hostnamectl的命令帮助

[root@server-01 ~]# hostnamectl --help hostnamectl [OPTIONS] COMMAND Quer

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/95221.html

(0)
上一篇 2026-03-16 21:00
下一篇 2025-05-10 12:45

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信