当前位置: > CentOS > CentOS入门 >

Change Hostname in CentOS 6.5/7

时间:2016-03-22 00:46来源:linux.it.net.cn 作者:IT

Change Hostname in CentOS 6.5/7

CentOS 6.5

[1] Change hostname with a commnad (but if rebooting, it will be back).

[root@vpsmate ~]# hostname              # show current hostname
srv1.vpsmate.net
[root@vpsmate ~]# hostname srv2.vpsmate.net         # change hostname
[root@vpsmate ~]# hostname
srv2.vpsmate.net
[2] Change hostname permanently.

[root@vpsmate ~]# vi /etc/sysconfig/network     # change
HOSTNAME=srv2.vpsmate.net
[root@vpsmate ~]# exit
CentOS release 6.5
Kernel xxx
srv2.vpsmate.net login:                 # changed

CentOS 7

[1]Change hostname with a commnad (but if rebooting, it will be back).

[root@vpsmate ~]# hostname                  # show current hostname
srv1.vpsmate.net
[root@vpsmate ~]# hostname srv2.vpsmate.net         # change hostname
[root@vpsmate ~]# hostname
srv2.vpsmate.net
[2] Change hostname permanently.

view source
[root@vpsmate ~]# vi /etc/hostname          # change
srv1.vpsmate.net
[root@vpsmate ~]# exit
CentOS Linux 7
Kernel 3.10.0-123.4.2.el7.x86_64 on an x86_64
srv1 login:                         # just changed
 
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容