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

This question already has an answer here:

~/bin$ cat setbrightness 
echo $1 > /sys/class/backlight/intel_backlight/brightness

~/bin$ whoami

~/bin$ sudo -l
Matching Defaults entries for rag on this host:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User rag may run the following commands on this host:
    (root) NOPASSWD: /home/rag/bin/setbrightness
    (ALL : ALL) ALL

EDIT: /etc/sudoers

Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification
Cmnd_Alias   SETBRIGHTNESS = /home/rag/bin/setbrightness

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Run command

~/bin$ sudo /home/rag/bin/setbrightness 3000
[sudo] password for rag:

Can someone please point out why the password is prompted when running sudo for that command?

share|improve this question

marked as duplicate by Gilles, jasonwryan, vonbrand, Renan, n0pe Mar 11 '13 at 2:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

What does the actual sudoers file have in it? Perhaps it's an order thing, for some reason the (ALL:ALL) ALL is getting matched first? – Dave C Mar 10 '13 at 1:09
i have now added /etc/sudoers – rag Mar 10 '13 at 1:18
up vote 7 down vote accepted

It's the order - if I replicate your sudoers file with:

Cmnd_Alias   TESTCOMM = /bin/more
root    ALL=(ALL:ALL) ALL
%admin  ALL=(ALL) ALL
%sudo   ALL=(ALL:ALL) ALL

I get the same behaviour e.g. doing sudo more asks for a password, same as sudo .


Cmnd_Alias   TESTCOMM = /bin/more
root    ALL=(ALL:ALL) ALL
%admin  ALL=(ALL) ALL
%sudo   ALL=(ALL:ALL) ALL

Let's me use more without a password, just prompting for anything else.

I guess this is due to the order which which things are checked in sudo (bottom-to-top).

share|improve this answer
yes, it seems to be the problem with order. I do not understand then why the file has this particular order of sections if it is problematic. is it particular to linux mint? the default order is 1. user privelege specification followed by 2. members of group sudo – rag Mar 10 '13 at 18:39
My test showing the difference was on Ubuntu 12.10 so it's not specific I think. What I don't know is if this is normal operation or a bug, but I would guess normal operation otherwise it would be being shouted from the rooftops. – Dave C Mar 11 '13 at 11:29

How did you edit the sudoers file? To verify a valid sudoers file ALWAYS use the visudo command and NEVER edit the sudoers file directly. This looks to be one of those cases.

share|improve this answer
i edited using visudo. also you can see in sudo -l it displays the configuration as done through visudo – rag Mar 10 '13 at 11:42

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