Centos7.5.1804永久生效修改主机名

原来主机名

[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 ~]# 

猜你喜欢

转载自www.cnblogs.com/xiaoai666/p/9288230.html
今日推荐