Centos 修改主机名
所有版本下临时修改主机名
hostname 新主机名, 没有多少应用场景, 意义不大
永久修改主机名
环境 1:centos 6.9
/etc/sysconfig/network
将 HOSTNAME=localhost.localdomain 修改为新主机名
/etc/hosts
不建议按网上说法修改 127.0.0.1 记录, 建议新增一条: IP 地址? 新主机名
重启生效
环境 2:centos 7.5
方法 1: 修改 / etc/hostname
方法 2:hostnamectl 命令
hostnamectl set-hostname Centos7.5
重启生效
来源: http://www.bubuko.com/infodetail-2695402.html