1.症状:
当你是使用sudo来执行命令时,总是在命令执行时,首先输出:“sudo:unable to resolve host Lily-desktop”(假设Lily-desktop 是你的当前主机的名字(host-name)), 但是怎样才能使使用sudo像以前一样不错误提示,正常工作呢。
when you’re running commands with sudo at beginning.It outputs “sudo:unable to resolve host Lily-desktop”(here assume current host-name is Lily-desktop),however the commands work as well as before.
2.产生该症状的原因:
这种症状经常发生在更改了hostname的情形下。在通过 编辑 /etc/hostname 改变了主机名字(hostname)之后, 我们还需要改变 /etc/hosts文件的相应部分的内容
This always happens after host-name changed.After change host-name by edit /etc/hostname,we also need to do a change in /etc/hosts file.
3.解决方案:
Solve: Edit /etc/hosts: // 编辑 /etc/hosts 文件
gksudo gedit /etc/hostsmake it looks like (change boldfaced words to current host-name): //使粗体字对应的词与当前的主机名即hostname 一致
127.0.0.1 localhost 127.0.1.1 Lily-desktop # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts本文的原始链接:http://ubuntuguide.net/fix-ubuntu-sudo-errorunable-to-resolve-host
You must have a host file problem. Please post this:
Code: Prompt>sudo cat /etc/hostsThis is a correct /etc/hosts file entry:
Code: 127.0.0.1 localhost 127.0.1.1 jason.laptop # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhostsSometimes using the Network-Manager tool it will add a suffix to the localhost entry causing this. Make your change to the host file and try again. HTH,
i try to do that i got this tonjaa@tonjaa-desktop:~$ sudo cat /etc/hosts sudo: unable to resolve host tonjaa-desktop 127.0.0.1 localhost 127.0.1.1 tonjaa-desktop.domain.com # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts then how i can do for resolve ?
should be:
Code: 127.0.1.1 tonjaa-desktopSo to edit it:
Code: sudo vi /etc/hostsor
Code: sudo gedit /etc/hostsThis should do it for you. Once you have edited the file. Save it and try again. HTH, Jaysunn