I am trying to execute a bash script as root from a normal user. The story behind is that I need the www-data user to be able to kill a specific process. To avoid having apache being able to go mayhem on processes I've created the following bash script
#!/bin/bash
PID=$(pgrep mono)
kill -9 $PID
To be able to perform this, I have done an apt-get install sudo
and then with visudo
added the following line to the bottom of the file
myuser ALL= NOPASSWD: /path/to/script/foo.sh
But when I sign into myuser and try to run /path/to/script/foo.sh
I receive the following error -bash: /path/to/script/foo.sh: Permission denied
The current permission of the file are as follows
-rwxr-xr-x 1 root root 48 Nov 7 12:11 foo.sh
Thank you!