码迷,mamicode.com
首页 > 其他好文 > 详细

centos7更改主机名

时间:2018-03-02 20:57:18      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:主机   /etc   主机名   lin   release   linu   使用   nbsp   smp   

操作环境

[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

 

centos7更改主机名

标签:主机   /etc   主机名   lin   release   linu   使用   nbsp   smp   

原文地址:https://www.cnblogs.com/lyjing/p/8494727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!