Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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
sudo "chmod +x /usr/bin/apt-fast"
"chmod +x /usr/bin/apt-fast"
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.
Required, but never shown