CentOS如何修改主机名称

OS:CentOS Linux release 7.5.1804 (Core)

查看主机名称:hostname
查看操作系统版本:uname -a
修改主机名称:hostnamectl set-hostname node-1

[root@centos-7 ~]# hostname
centos-7.shared
[root@centos-7 ~]# uname -a
Linux centos-7.shared 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@centos-7 ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
[root@centos-7 ~]# 
[root@centos-7 ~]# 
[root@centos-7 ~]# hostnamectl set-hostname node-1
[root@centos-7 ~]# hostname
node-1

[root@centos-7 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@centos-7 ~]# vim /etc/hosts
[root@centos-7 ~]# 
[root@centos-7 ~]# 
[root@centos-7 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 node-1
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@centos-7 ~]# 

你可能感兴趣的:(CentOS如何修改主机名称)