Is it safe to add this command in sudoers file?

mike ALL= NOPASSWD:/bin/chown -R www-data\:www-data /var/www

and this is the only command that I want to run

$mike@ubuntu: sudo chown -R www-data:www-data /var/www

Thank you.

up vote 6 down vote accepted

Yes.

From man sudoers:

   If a Cmnd has associated command line arguments, then the arguments in
   the Cmnd must match exactly those given by the user on the command line
   (or match the wildcards if there are any).  Note that the following
   characters must be escaped with a '\' if they are used in command
   arguments: ',', ':', '=', '\'.  The special command "sudoedit" is used
   to permit a user to run sudo with the -e option (or as sudoedit).  It
   may take command line arguments just as a normal command does.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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