Sudo hangs without prompting for password

I just did a fresh install of Ubuntu and now when I try to use sudo in the terminal emulator, it just hangs there without even asking me for a password. If I switch to the terminal (Ctrl + Alt + F1) and login, sudo works as expected. Can someone help me to figure this out?

4

4 Answers

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
4

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.

4

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.

I too had this problem with Ubuntu 16.04 . Using "top" command i found that two processes "vnstat" and "NetworkManager" are consuming 100% CPU. So i restarted the system, went to recovery mode and removed the package "vnstat" . After this restarted the system , now system works fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like