Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

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
share|improve this question

migrated from stackoverflow.com Jan 4 '12 at 17:26

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

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
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
up vote 7 down vote accepted

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.

share|improve this answer

Your Answer


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

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