首页 > 开发 > linux > 正文

linux修改hosts并生效

2017-10-27 16:42:26  来源: 网友分享

修改/etc/hosts之后正常情况应该是保存之后立即生效的,但是有时不是。使用uname-a 可以查看hostname是多少,就可以知道是否修改生效了。如果没有

这时的策略有:

1) 重启机器

2) 重启服务

     Ubuntu: $sudo/etc/init.d/networking restart
     Gentos: /etc/init.d/net.eth0restart
     或
     service network restart

3)使用hostname命令

 hostname 定义的主机名