Sudo hangs without prompting for password

Have you changed the hostname recently? I've noticed after a hostname change sudo can hang for a bit. However, if you update your hosts file to reflect the hostname change the hang will go away.

You can do that with this simple one-liner:

hostname | (echo -n "127.0.0.1        " && cat) | sudo tee -a /etc/hosts

If you want to check where it hangs, I suggest doing the executing the following command:

 strace sudo 

and then see what system call it is possibly hanging on. This might provide a good clue as to what is happening on your system.

My guess based on what you see is that hostname resolution is problematic on your system. Check out /etc/nsswitch.conf and /etc/resolv.conf files to make sure they are configured properly.

I have assummed that you have already checked your internet connectivity.


I am not sure which version of ubuntu you have installed, but there is a bug (race condition) in sudo, which hangs indefinitely blocking on a select.

https://bugzilla.sudo.ws/show_bug.cgi?id=447