Situation:
I\'d like to execute a shellscript directly from a web-gui. The shellscript belongs to the user \"tux\". Since my webserver is running as
You can add your user tux to /etc/sudoers with NOPASSWD to allow it to run sudo without password prompt.
E.g. add this to the end of /etc/sudoers to allow elevated execution of any command without password (note, there's a special tool for that - visudo):
tux ALL=(ALL) NOPASSWD: ALL
Or, a more restricted way - only allow this for your script:
tux ALL = NOPASSWD: /opt/tomcat/bin/shutdown.sh
After that check that the changes are in effect by running any command from terminal, e.g.:
sudo id
and it should not prompt for root password.
UPDATE:
To make Apache run a script that belongs to another user (e.g. tux) add this line to sudoers:
www-data ALL=(ALL) NOPASSWD: /bin/bash /opt/tomcat/bin/shutdown.sh
Then you should be able to run it without password like so:
sudo -u tux /opt/tomcat/bin/shutdown.sh
Also, check these: