Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
%admin ALL=NOPASSWD: ALL
share|improve this question
    
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
add comment

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

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

1 Answer

up vote 6 down vote accepted

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

%admin ALL=(ALL) NOPASSWD: ALL

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
add comment

Your Answer

 
discard

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.