sudo: unable to resolve host - solution Linux

This happens because you don't have your hostname configured in the hosts file.

in my case I have the following hostname XserverA and I get the following error:

 

sudo: unable to resolve host XserverA 

 

In order to solve it

We edit the hosts file with the following command:

sudo nano /etc/hosts

 

We will find the following information for example:


127.0.0.1 localhost
127.0.1.1 ubuntu

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

We will add our hostname as I put it:

127.0.0.1 localhost
127.0.1.1 ubuntu XserverA

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

You add yours, then close the editor with the keys Ctrl + X, then press Y then Enter.

Was this answer helpful? 0 Users Found This Useful (0 Votes)