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 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?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

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
share|improve this answer
add comment

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
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.