sudo 出现unable to resolve host 解决方法

http://blog.csdn.net/ichuzhen/article/details/8241847Ubuntu环境, 假设这台机器名字叫abc(机器的hostname), 每次执行sudo 就出现这个警告讯息:
sudo: unable to resolve host abc
虽然sudo 仍是能够正常执行, 可是警告讯息每次都出来,而这只是机器在反解上的问题, 因此就直接从/etc/hosts 设定, 让abc(hostname) 能够解回127.0.0.1 的IP 便可.

/etc/hosts 原始内容node

          127.0.0.1       localhostoop

          # The following lines are desirable for IPv6 capable hosts .net

          ::1     localhost ip6-localhost ip6-loopback ip6-loopbackrouter

         fe00::0 ip6-localnet 
         ff00::0 ip6-mcastprefix 
         ff02::1 ip6-allnodes
         ff02::2 ip6-allrouters blog

         ff02::3 ip6-allhosts  ip

 

         在127.0.0.1 localhost 后面加上主机名称(hostname) 便可, /etc/hosts 内容修改为以下:ast

127.0.0.1       localhost abc  #要保证这个名字与 /etc/hostname中的主机名一致才有效
# 或改为下面这两行 
#127.0.0.1       localhost 

#127.0.0.1       abcroute

这样设完后, 使用sudo 就不会再有那个提示信息了。hosts

相关文章
相关标签/搜索