Debian环境, 假设这台机器名字hostnamesever, 每次执行sudo 就出现这个警告讯息:

sudo: unable to resolve host abc

虽然sudo 还是可以正常执行, 但是警告讯息每次都出来,而这只是机器在反解上的问题, 所以就直接从/etc/hosts 设定, 让sever(hostname) 可以解析回127.0.0.1 即可.

/etc/hosts 原始内容

          127.0.0.1       localhost
          102.203.186.21  ro361.freesever.ro
          # The following lines are desirable for IPv6 capable hosts

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

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

127.0.0.1 localhost 后面加上主机名称sever 即可,要保证这个名字与 /etc/hostname中的主机名一致才有效.
/etc/hosts 内容修改成如下:

127.0.0.1       localhost sever  

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

参考

Last modification:September 8, 2019
如果觉得我的文章对你有用,请随意赞赏