2

I am new to bash. I need to write the script which executes the following commands consecutively su - bbt; id

and to see the result. I have tried to put this line into the tmp.sh and then run it. I just see the results of the first command su - bbt. I don't see the results for the id command.

1 Answer 1

1

Try this:

su -c 'bbt; id'

Sign up to request clarification or add additional context in comments.

4 Comments

Did you mean: sh -c 'su - bbt; id'?
su -c will relay to sh -c (in the new session)
I got your question wrongly. You want to change the user as 'bbt' and then run the command 'id', right? Then you should try as: su - bbt -c 'id'
The command I wrote in my initial comment would work differently. It would execute the commands 'bbt' and 'id' sequentially with root privileges.

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.