我正在学习 RHEL 7 并有一些问题。
使用hostnamectl
命令,我正在获取 RHEL 7 主机名和其他信息。
如果我想更改主机名,有一些选项可以使用hostnamectl
:
[root@linux7 ~]# hostnamectl set-
set-chassis set-deployment set-hostname set-icon-name
Run Code Online (Sandbox Code Playgroud)
要更改主机名,使用静态主机名set-hostname
。那么,关于set-icon-name
与--pretty
和特定的文件时,它得到改变?
给出了下面的例子:
[root@linux7 ~]# hostnamectl set-hostname Linuxindia
[root@linux7 ~]# hostnamectl set-icon-name mumbailinux
[root@linux7 ~]# systemctl restart systemd-hostnamed.service
[root@linuxindia ~]# hostnamectl set-
set-chassis set-deployment set-hostname set-icon-name
[root@linuxindia ~]# hostnamectl set-hostname "hellolinux" --pretty
[root@linuxindia ~]# hostnamectl status
Static hostname: linuxindia
Pretty hostname: hellolinux
Icon name: mumbailinux
Chassis: vm
Machine ID: f3ffdd0447604e20a0a4278c56f4275b
Boot ID: 70c3c85ec1fa4dceb5a7f52789eed524
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.3 Beta (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:beta:server
Kernel: Linux 3.10.0-493.el7.x86_64
Architecture: x86-64
[root@linuxindia ~]#
Run Code Online (Sandbox Code Playgroud)
还请求获取有关瞬态主机名的一些信息。
图标名称是根据XDG 图标命名规范的机器识别名称。
当--pretty
使用时,机器漂亮主机名设置。这个名字是人类可读的名字,呈现给用户,而不是机器。它没有互联网域名的限制,您可以使用任何有效的 UTF-8 名称作为它:
$ hostnamectl --pretty set-hostname "$(perl -CO -le 'print "\x{1f389}"')"
$ hostnamectl --pretty status
Run Code Online (Sandbox Code Playgroud)
请注意,虽然 DNS 允许域名最多 255 个字符,但 Linux 中的主机名仅限于 64 个字符:
$ hostnamectl set-hostname "$(perl -le 'print "A" x 65')"
$ awk '{print length}' /etc/hostname
64
Run Code Online (Sandbox Code Playgroud)
将hostname
被存储在/etc/hostname
,pretty name
并且icon name
存储在/etc/machine-info
。
归档时间: |
|
查看次数: |
18019 次 |
最近记录: |