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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.