Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo: unable to resolve host ServerName (takes very long time to "sudo su" ) [closed]

I use vmware and install ubuntu 12.10 as my guest OS. and run my pc , my network interface is a wireless card however everytime when i try to sudo , i should wait for a long time. and echo

sudo: unable to resolve host ServerName pocUbuntu
[sudo] password for poc: 

I search almost solutions by google , there is no solution can fix my problem.

when i type hostname

root@ServerName pocUbuntu:/home/poc# hostname
ServerName pocUbuntu

and there is my hosts file

 cat /etc/hosts
127.0.0.1   localhost pocUbuntu
127.0.0.1   pocUbuntu
127.0.1.1   pocUbuntu

# 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

and i can get the ack when ping the servername pocUbuntu

root@ServerName pocUbuntu:/home/poc# ping pocUbuntu
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.026 ms

how should i do ? to fix the annoying problem.

like image 730
newBike Avatar asked Mar 26 '13 14:03

newBike


People also ask

How do I fix sudo unable to resolve host?

Since the hostname is missing and your system is not able to figure out the hostname and thus it throws the error 'sudo: unable to resolve host'. To fix this error, edit the /etc/hosts file and set the hostname (newpc) with a loopback address (127.0. 0.1).

Why does sudo need to resolve the hostname?

The /etc/sudoers file is designed to be able to be distributed among multiple servers. In order to accomplish this, each permission in the file has a host portion. In order for sudo to know wether this rule should be applied, it needs to lookup the host it is running on.


1 Answers

try this: /etc/hosts

127.0.0.1 localhost
127.0.1.1 hostname:localdomain hostname

or:

127.0.0.1 localhost
like image 62
Exceptyon Avatar answered Oct 10 '22 23:10

Exceptyon