Cant' use sudo: unable to resolve host ....

Created by marcobra (Marco Braida)
Keywords:
sudo unable to resolve
Last updated by:
marcobra (Marco Braida)

PROBLEM:

The user cant' use sudo the system show... for example something like this:

dwinningham@dwinningham-laptop:~$ sudo dpkg --configure -a

sudo: unable to resolve host dwinningham-laptop

SOLUTION:

Seems like this: https://answers.launchpad.net/ubuntu/+source/gnome-terminal/+question/31069

Into the /etc/hosts file there must be the computer name
lshw | head -1
give me "ubuntu" is my computer name

and into my /etc/hosts i have:
127.0.0.1 localhost ubuntu
127.0.1.1 ubuntu

So please check yours

You must edit the /etc/hosts file as root but sudo is not working so:

Please Start the pc the when you see the GRUB row...
Press ESC.

Press "e" for edit.

Highlight the line that begins kernel ………, and press "e"

Go to the very end of the line, add rw init=/bin/bash

press enter, then press "b" to boot your system.

Your system will boot up to a passwordless root shell.

You can edit the /etc/hosts file with nano editor type

nano /etc/hosts

to reboot the pc please type

reboot

Hope this helps