0

I need to execute an install script using sudo, but towards the end of the script, the script needs to drop out of sudo and continue as the regular user.

Example:

sudo ./install.sh

script runs and does what it needs to as root

su myscriptuser
service myscript start

Basically, the service myscript start needs to be run by the regular user, not by root.

1 Answer 1

1

su myscriptuser starts another shell in the name of myscriptuser and waits until it exits. Then it proceeds to run service myscript start in the name of root again.

What you need instead of the last 2 commands is sudo:

sudo -u myscriptuser service myscript start
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.