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.
sudo
in a script – if the whole script runs as root (called by e.g.cron
or withsudo /path/to/script
) there's no need forsudo
inside it. – dessert Oct 06 '17 at 21:42sudo
in a script to avoid running a particular command as root. The password will only be requested when the command is encountered see test – Zanna Oct 07 '17 at 09:20