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?
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:
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.
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.