关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

云服务器centos7永久更改主机名

发布时间:2020-02-25 14:06:55
1491984010112764.jpg

操作环境:

[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
复制代码

如下图:



/template/Home/8a/PC/Static