Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Error message “sudo: unable to resolve host (none)”

When I run sudo the terminal is stuck for a few seconds and then outputs an error message. My terminal looks like this:
ubuntu@(none):~$ sudo true
sudo: unable to resolve host (none)


What can I do to solve it?
by

3 Answers

akshay1995
Two things to check (assuming your machine is called my-machine, you can change this as appropriate):

That the /etc/hostname file contains just the name of the machine.

That /etc/hosts has an entry for localhost. It should have something like:

127.0.0.1 localhost.localdomain localhost
127.0.1.1 my-machine

If either of these files aren't correct (since you can't sudo), you may have to reboot the machine into recovery mode and make the modifications, then reboot to your usual environment.
sandhya6gczb
Add your hostname to /etc/hosts like so:

echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts
pankajshivnani123
I had this issue when I was using ubuntu on a VPS. I solved it editing /etc/hosts file.

run this command:

sudo nano /etc/hosts

and then add:

127.0.0.1   localhost.localdomain localhost
127.0.1.1 ubuntu

I hope that will solve your issue :)

PS: Remember to reboot your computer!

Login / Signup to Answer the Question.