Shell – Allow another user to run a specific script as the ID

privilegesshell-script

I have a script somewhere in my home directory. I need to give another user or a group permissions such that when they execute that specific script, it executes as though I am logged in and has all permissions that my ID has. I do not want to use sudo or su and go through setting them as sudoers or entering passwords.

Best Answer

With sudo you can get very granular with your permissions. If you want to give a user permission to only run your script and nothing else you can add this line to your /etc/sudoers:

user ALL=(yourusername) NOPASSWD: /path/to/your/script

Then, as the other use, you would run:

sudo -u yourusername /path/to/your/script
Related Question