09-25-2013 08:22 AM
User_Alias ADMINS = user1, user2
root ALL = (ALL) ALL
ADMINS ALL = NOPASSWD: ALL
--> 1.Can you explain me the Line 1,2 3.
--> 2.suppose if i am adding user3 instead of root in Line 2 ,at this point what it refers to.
09-25-2013 12:10 PM
> User_Alias ADMINS = user1, user2
This defines an "user alias": a collective name for a set of one or more users, for the purpose of identifying the users who can do something with sudo.
There are other alias types: Host_Alias for defining a set of hosts, Runas_Alias for defining a set of users someone can run commands as, and Cmnd_Alias for defining a set of commands you might allow to be run through sudo.
You don't *have* to use any of these aliases, but if your sudo configuration is complex, the aliases will allow you to group things so you don't have to repeat long lists of users/hosts/commands.
> root ALL = (ALL) ALL
This is the basic form of a sudoers user specification.
It says that root is allowed to use sudo on all hosts using this sudoers file, to run all possible commands, as any user.
When a sudoers file is used on a single host, most sysadmins won't bother using the actual hostname in the hosts field; they will type "ALL" in the host field instead.
If you have a centrally managed sudoers file that is used on multiple hosts, you can use the hosts field to restrict some sudoers user specifications to a particular (set of) host(s) only.
> ADMINS ALL = NOPASSWD: ALL
This is another user specification, using the ADMINS user alias defined on line 1.
It also has the NOPASSWD tag, indicating that no password prompt will be presented before running the command.
The users listed by the ADMINS user alias may run all commands as root (if the run-as field is omitted, the default value of (root) is assumed.
So, line 3 could is exactly equivalent to:
user1, user2 ALL = (root) NOPASSWD: ALL
You might want to write a comment like this as a syntax reminder to your sudoers file:
# <WHO does> <WHERE> = (<as WHO>) <WHAT>