If you are ever working on a freshly deployed Linux machine and start getting an error like
sudo: unable to resolve host your-hostnamewhen trying to run a command, then it is probably a good idea to check your
The key is to make sure that in that in that file your computers hostname is properly populated.
I saw this askubuntu post and I am not sure if the file also needs the line that reads
127.0.0.1 localhost.localdomain localhost or not. Interestingly enough, mine seems to be working fine without it.
If you need to check what your hostname is, you can try looking at your prompt or running a command like:
I asked around and apparently the
hosts file is actually what existed before DNS was ever invented. Computers would keep just a file that mapped ip addresses to hostnames. Then people would pass around
hosts files. This could cause a lot of security issues if a hacker edited your hostname file and mapped the hostname for webcrawler to their own computer's ip!
I am not sure why but the Ubuntu image I was using within OpenStack didn't have the localhost ip in that file.
As usual, feel free to contact me if you come across any errors in this post!