sudoers - simple explanation requested

Posted by Redsandro on Ask Ubuntu See other posts from Ask Ubuntu or by Redsandro
Published on 2012-04-02T14:25:04Z Indexed on 2012/04/06 17:42 UTC
Read the original article Hit count: 240

Filed under:
|

Everytime I want to be able to run something that requires me to be a sudoer too many times, I need to google for the formatting of /etc/sudoers to remind me again what exactly is the proper way to write it.

Now I see different writing styles in my sudoers file, which is the consequence of different google results over the months. I've also noticed that the second example (below) seems to work in XFCE, but not in Cinnamon (Gnome 3). This could be totally unrelated, but nontheless I'd like to know once and for all, what is the correct grammar of the sudoer line, and what is the difference between the given examples?

  1. redsandro ALL=NOPASSWD:/path/to/command
  2. redsandro ALL=(ALL) NOPASSWD:/path/to/command
  3. redsandro ALL=(ALL:ALL) NOPASSWD:/path/to/command

Also, what are all the ALL's for? One user, one command, yet I need to use the ALL keyword up to three times? Am I doing this wrong?

Of course, omitting NOPASSWD: makes you enter your password before you are permitted to run the command, but one point of confusion is the usage of = and :, for the final command that is the subject of the line can be prepended by either =, :, , or ), confusing grammar for similar semantics.

© Ask Ubuntu or respective owner

Related posts about sudo

Related posts about sudoers