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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM