Home > centos > centos修改主机名立即生效

centos修改主机名立即生效

April 15th, 2010 Leave a comment Go to comments   988 views

 

第一步:
shell 命令 #hostname yourhostname 

第二步:
修改/etc/sysconfig/network中的hostname
[root@suzhouP ~]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
#HOSTNAME=localhost.localdomain
HOSTNAME=yourhostname

~

第三步:
修改/etc/hosts文件
[root@suzhouP ~]# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost yourhostname
::1 localhost6.localdomain6 localhost6

exit注销后重新登录即可,如果不行请重启centos.

  • Share/Bookmark
You must be logged in to post a comment.