Ubuntu – 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?

Best Answer

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 "        " && cat) | sudo tee -a /etc/hosts
Related Question