原來主機名
[root@node1 ~]#
查看Centos的版本:
[root@node1 ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
確定版本后,Centos7特地添加了hostnamectl命令查看和修改:
[root@node1 ~]# hostnamectl Static hostname: node1 Icon name: computer-vm Chassis: vm Machine ID: ef4a922d17fb4282a34a47c69588ffad Boot ID: 0ab461ff770745c8a7a4d59ede5888df Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-862.2.3.el7.x86_64 Architecture: x86-64
對主機名進行修改:
[root@node1 ~]# hostnamectl set-hostname xxxxx
查看是否修改成功:
[root@node1 ~]# cat /etc/hostname
xxxxx
若是使用Xshell客戶端進行修改的,可以斷開后再連接,即可看到修改后的主機名:
[root@xxxxx ~]#