Question about using sudo su
Hi,
I have a need to run a script as another user, but the current process takes three commands to do. sudo su - user cd directory/ ./script.sh The account is set up such that doing the 'sudo su - user' requires no password. I am trying to get this into a single command or shell script which I can run to accomplish the same thing. I tried using the -c flag of su, however I am required to enter a password with this flag. I can't enter a password, since I haven't been given a password. Any help would be appreciated. Thanks, Beau |
Disregard this.
|
Can you not put
Code:
su - user -c "cd /path/to/directory && ./script" runme.sh w/o a password and then do sudo runme.sh? Cheers, Tink |
sudo su is superfluous. Use either sudo or su, you don't need both together.
If you want your script run as a different user, use any of these: sudo -u user directory/myscript.sh sudo -u user sh -c 'cd directory; ./myscript.sh' |
Quote:
Thanks again, Beau |
The su program does not use sudoers; only sudo users sudoers.
|
All times are GMT -5. The time now is 05:10 PM. |