永久生效
hostnamectl set-hostname xxx
重启CentOS 7
reboot -f
重启之后
[root@slave ~]# hostname
slave
[root@slave ~]# hostnamectl
Static hostname: slave
Icon name: computer-vm
Chassis: vm
Machine ID: de9caab1c8ca4e30aacedb8e7b0735f5
Boot ID: 22954f60cc8f4034a9064dfafb75e93d
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
[root@slave ~]#