5

I know in /etc/sudoers, one can put Defaults rootpw, but then sudo asks for the root password for all commands. Is there any way I can have sudo ask for the root password for some commands and the user password for others?

2 Answers 2

5

Defaults can be set for everything or for certain Hosts, Users or Commands

man sudoers says :

Defaults Certain configuration options may be changed from their default values at runtime via one or more Default_Entry lines. These may affect all users on any host, all users on a specific host, a specific user, a specific command, or commands being run as a specific user. Note that per-command entries may not include command line arguments. If you need to specify arguments, define a Cmnd_Alias and reference that instead.

    Default_Type ::= 'Defaults' |
                     'Defaults' '@' Host_List |
                     'Defaults' ':' User_List |
                     'Defaults' '!' Cmnd_List |
                     'Defaults' '>' Runas_List

So try :

Defaults!cmdlist rootpw
2

You can turn turn off root password for specific commands and specific users by adding this line to /etc/sudoers:

username1 hostname1 =NOPASSWD: /usr/bin/command_name1,/usr/bin/command_name2
username2 hostname2 =NOPASSWD: /usr/bin/command_name1,/usr/bin/command_name2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .