linux – How can I execute a series of commands in a bash subshell as another user using sudo? – Stack Overflow
Posted by jpluimers on 2021/03/31
Based on [WayBack] linux – How can I execute a series of commands in a bash subshell as another user using sudo? – Stack Overflow:
alias restart-spotlight-service-as-root="sudo bash -c 'echo stop;launchctl stop com.apple.metadata.mds;echo start;launchctl start com.apple.metadata.mds;echo started'"
The bold bits above sudo bash -c 'echo stop;launchctl stop com.apple.metadata.mds;echo start;launchctl start com.apple.metadata.mds;echo started'
allow the commands between single quotes to executed in one new bash shell under sudo.
–jeroen
Leave a Reply