在安装centos7时,设置的主机名称是root,后面想更改成localhost:
hostnamectl set-hostname localhost
'
而后,重启服务reboot后可查看到主机名称已经更改过来: