I have a virtual machine running ubuntu server (latest LTS forget the actual version number). I have setup sudo not to ask for a password but when I did that I could no longer run psql as postgres user using sudo -u unless i was root.

sudo -u postgres psql

I now get a password prompt and then this message after i enter my password ...

Sorry, user _____ is not allowed to execute '/usr/bin/psql' as postgres on ...

sudoers file

root ALL=(ALL) ALL
  • Any idea why the down vote? Not bothered but would help to know so that in the future my questions can better. – Ominus Jan 4 '12 at 15:24
  • 1
    I didn't downvote you, but you should probably post these types of questions to either superuser.com or askubuntu.com. – mevatron Jan 4 '12 at 15:26
  • As @mevatron stated, your question is off topic (I didn't downvote it btw). Read the faq to know what kind of questions belong on SO – Anzeo Jan 4 '12 at 15:43
  • Thanks. Do i as the OP have a way to move the question or should i not ever bother since i have the answer i needed. – Ominus Jan 4 '12 at 15:46

Assuming your user is in the admin group, modify the second line to


to allow passwordless sudo to every user, not only root. Your current config allows

  • root to run anything as anyone
  • users from the admin group to run anything as root without password

as there is no runas-specification (ALL) making it possible to run as anyone.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.