Why does sudo take so long to ask for password?

Everytime I ran the sudo command, it took about 3-10 seconds to ask for the password. I found that the reason for this is that sudo does a DNS lookup. There was a problem with my /etc/hosts file. I had changed the hostname of the computer without updating the /etc/hosts file. The fix was to add a record for my computer. For example:

127.0.1.1       myComputerHostname

Leave a Reply