The following will allow newuser to run any commands anywhere? How can I prevent it by allowing the user to run certain commands only?

visudo

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
newuser ALL=(ALL)       ALL
link|improve this question

67% accept rate
feedback

2 Answers

up vote 4 down vote accepted

You can create a command alias for newuser e.g.

Cmnd_Alias    NEWUSER_CMDS = /path/to/cmd1, /path/to/cmd2, /path/to/cmd3

then use that as part of the user specification

newuser ALL=(ALL) NEWUSER_CMDS 
link|improve this answer
feedback
newuser ALL=(ALL)       /path/to/your/command

Read User Specification section in the man sudoers page for more details.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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