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