I’m writing a bash script that needs to sudo multiple commands. I can do this:
( whoami ; whoami )
but I can’t do this:
sudo ( whoami ; whoami )
How do I solve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Run a shell inside
sudo:sudo bash -c 'whoami; whoami'You can use any character except
'itself inside the single quotes. If you really want to have a single quote in that command, use'\''(which technically is: end single-quote literal, literal'character, start single-quoted literal; but effectively this is a way to inject a single quote in a single-quoted literal string).