Centos7 永久更改主机名

操作环境:

[root@bogon ~]# uname -a
Linux #localhost.localdomain 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux
[root@bogon ~]# cat /etc/redhat-release 
CentOS release 7.3.1611 (AltArch) 
[root@bogon ~]# 

实验要求:将Centos7原主机名改为'NMserver-7.test.com'

1、方法一使用hostnamectl命令

[root@bogon ~]# hostnamectl set-hostname  NMServer-7.test.com

2、方法二:修改配置文件  /etc/hostname 保存退出

[root@bogon ~]# vi /etc/hostname 
 nmserver-7.test.com

:wq
[root@bogon ~]# reboot

原文地址:https://www.cnblogs.com/me80/p/7218488.html

原文地址:https://www.cnblogs.com/nethrd/p/9706781.html