Thank you for your response, but I think you misunderstood the problem.
Per this post on the CircleCI blog, sudo should not ask for a password on a CircleCI build machine, and this is how CircleCI machines have worked until recently.
The reason that sudo is timing out is not because the command takes a long time to run, but because sudo asks for a password (which it should not) and times out waiting for the password to be entered.
Finally, sudo on CircleCI only asks for a password on Ubuntu 12.04, not on 14.04. This leads me to suspect that it’s some kind of configuration problem on the Ubuntu 12.04 image.