Today’s blog is about a simple issue you sometimes encounter after you rename your machine’s hostname.
Issue:
whoareyou@xenial:~$ sudo cat /etc/hostnameUnable to resolve hostname xenialPlease enter your password:
This issue occurred to me just recently when I renamed my machine name from whoareyou to xenail.
Everytime I encountered this “Unable to resolve hostname xenial” issue
Earlier while I checked my hostname with command sudo cat /etc/hostname the result was xenial.
whoareyou@xenial:~$ sudo cat /etc/hostnamexenial
But the hostname was not listed inside /etc/hosts. I checked with command sudo cat /etc/hosts
whoareyou@xenial:~$ sudo cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 whoareyou
The exact reason for why the host xenial wasn’t listed in hosts is yet unknown. But in order to resolve the issue, I did this simple tweak.
I renamed the hostname xenial from /etc/hostname to whoareyou. and restarted the machine. Then after the issue was no more encountered. As simple as it is.