I wish to add a file to the /etc/sudoers.d
folder that includes a directive to allow www-data
to run one specific script with no root password.
The directive is
www-data ALL=(ALL) NOPASSWD: /path/to/script.sh
If I visudo
and add it to /etc/sudoers
, there is no problem.
If I put that line in a file and copy it to /etc/sudoers.d
, then visudo
, it tells me that the file has a 'syntax error near line 1'.
Is there something else I need to put in the file, or something else I need to do to make it work?
I am running Ubuntu 18.
Thanks!
I found out the problem - for files in /etc/sudoers.d, the file must not end at the directive, but on a new line. This is most easily shown with
cat -A
.Invalid file:
Valid file: