Linux – sudo taking long time

linuxpamsudo

On a Ubuntu 9 64bit Linux machine, sudo takes longer time to start. "sudo echo hi" takes 2-3 minutes.
strace on sudo tells poll("/etc/pam.d/system-auth", POLLIN) timesout after 5 seconds and there are multiple calls(may be a loop) to same system call (which causes 2-3min delay).

Any idea why sudo has to wait for /etc/pam.d/system-auth?
Any tunable to make sudo to timeout faster?

Thanks
Samuel

Best Answer

The largest cause of sudo being slow is the system not being able to resolve it's own hostname. Do you have your local hostname included in /etc/hosts? If not I would recommend adding it with the IP 127.0.1.1 which is what I do on all my systems. I add the entry with both the short hostname and the full qualified domain name (FQDN). This then removes the delay in sudo access calls 9 out of 10 times.