If I call a bash script with sudo
, for example:
sudo bash script.sh
Do I still have to use sudo
inside the script in cases like this:
sudo apt-get update
No. the command will be run with root privileges and all commands that the script runs will inherit the privileges.
no, by calling sudo you are running a process in kernal mode which means you have access to everything, you no longer have to use special permissions in different areas of your code/script.
sudo
can't find thechmod
command. Unless the command in the script issudo "chmod +x /usr/bin/apt-fast"
, which would causesudo
to look for a command named"chmod +x /usr/bin/apt-fast"
. (But in any case, you don't needsudo
inside the script.)$PATH
.