Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from May 10 '10 at 7:25

This question came from our site for professional and enthusiast programmers.

How responsive is your LDAP server? What is in /etc/pam.d/system-auth? – Kevin M Jun 13 '10 at 11:46

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

share|improve this answer

I can't help but think that the poll() call may be a red herring.

Whenever I have seen sudo being exceptionally slow, it has always been DNS that is at fault. Whether it's old, dead servers listed in /etc/resolv.conf or a misconfigured firewall that's blocking port 53 outbound or something else entirely, I have always found that dig is slow when sudo echo foo is slow.

Even if it is not DNS, I suspect the slowness is network related and possibly authentication related (as Kevin M suggested) in which case the poll() call may not be a red herring after all.

Try running a tcpdump while trying to run sudo and see what shows up.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.