要修改centos 的主机名为master, 有两处需要修改
/etc/sysconfig/network
$ sudo vim /etc/sysconfig/network
# 最终结果为
# Created by anaconda
NETWORKING=yes
HOSTNAME=master
/etc/hosts
将如下内容
$ sudo vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
修改为
127.0.0.1 localhost master localhost4 localhost4.localdomain4
::1 localhost master localhost6 localhost6.localdomain6
或者直接执行如下命令
hostnamectl set-hostname newName
重启即可