centos7更改主机名

操作环境

[root@centos701 ~]# uname
Linux
[root@centos701 ~]# uname -a
Linux centos701 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@centos701 ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

1、方法一使用hostnamectl命令

[root@centos701 ~]# hostnamectl set-hostname centos702

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

[root@centos701 ~]# vi /etc/hostname 

centos701
~                                                                                                                                                            
~                                                                                                                                                            
~                                                                                                                                                            
~                                                                                                                                                            
                                                                                                                                                          
:wq
[root@centos701 ~]# reboot

 

posted @ 2018-03-02 19:03  总被人想的静静  阅读(172)  评论(0编辑  收藏  举报