I'm about to write a script that requires some commands be executed with sudo and others be executed as the current user. I believe that if I sudo the script with
sudo script, then all the command in it will run as sudo. How to I exclude some of them to run as the current user?
Prefix each command that needs
sudo in the script with
sudo, in the script, and run the script as normal. (This can be a bit surprising when the first password prompt comes up, so it’s worth adding a message before the first
sudo in the script).