I ran in to the weirdest error today. “sudo: unable to resolve host”. I got this error even running as root which was the really weird part. I was especially confused because I have been running Linux as my main OS for the better part of 10 years and have never run into this issue. Turns out the solution is very simple and almost elementary however I decided to make a quick post about it.
Here is a screen shot of the issue. I actually had this on the Security Distro I work on called Backtrack. We made the newest build of our .iso with a new installer. Once I installed to hard disk, I got this error:
I got this error on every single .desktop file we had because most of Backtracks security tools need to be run as root so we add sudo -s to the end of every .desktop file in case people would rather create a user.
Turns out the issue was our installer. It had a issue with creating the /etc/hosts file. Apparently it wasn’t adding our host name properly. I did some looking and it seems the error is rather common from people forgetting to add their hostname to /etc/hosts. So here are a few pics of what i did.
/etc/hosts before:
/etc/hosts after:
So all did was change the hostname from backtrack to bt. This could have been a error somewhere in our development team. This is however a perfect example of why the hosts file is important on Linux/Unix based systems.
Problem solved: