Bash – How to get a program running with root privileges without using su or sudo

bashpermissions

I have a bash script that needs to run with root privileges, but must be invoked by the normal user.

Difficult part is that the script should not ask for a password, and I don't want to use the sudoers file. I'd like to avoid using sudo or su.

Is this possible?

Best Answer

If it wasn't a bash script but a regular application, you would give ownership of it to root and set the setuid bit on the application. Then upon execution, the effective user the application is running under is root. Due to security concerns however this is in many systems prohibited for shell scripts. This question here on unix.stackexchange.com does handle ways how to overcome this.

Related Question