This question already has an answer here:
I have bash-script that uses sudo commands, but in the middle I need to stop sudo-influence and then later reinstate it.
Very simple version using Pseudo code
sudo apt-get install -y synaptic sudo ... // I need to suspend sudo here, otherwise the folder // is created with root as the owner. mkdir ~/mystuff // then reinstate it here sudo apt-get install -y ssllib
Does sudo request the passphrase as soon as it starts to run a bash script - or- does it only ask when it encounters the first "sudo" line?
If so, then I think I may be able to move all the non-sudo stuff to the top. But, the problem there is I will have to wait until the first "sudo" line is encountered to then enter the passphrase.