Emmanuel O Emmanuel O - 7 months ago 20
Bash Question

Add sudo permission to a group of users for specific shell file

I have been looking for an answer for a while now, but I cannot find it.

I have a shell script located at: /home/myuser/shell.sh, which requires sudo to be run. I want all my users from

to be able to run it without password.

So I executed:
, and added this line at the end of the file:

%mygroup ALL=(ALL) NOPASSWD: /home/myuser/shell.sh

The problem is that it is not working. When I try to execute
sh /home/myuser/shell.sh
as one of the users of
, it asks me for the sudo password.

Can you help me?

Thanks a lot!


Run it with sudo

visudo affects sudo behaviour, so you have to use it.

But don't use sh /.../shell.sh, make the script executable first

chmod +x /home/myuser/shell.sh

then you'll be able to do

sudo /home/myuser/shell.sh

without the password. Then remove all sudo calls in the script.