2

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

4
  • 2
    Did you try it?
    – Cfreak
    Aug 9, 2011 at 19:15
  • Course. I am getting a strange error: "+ sudo chmod +x /usr/bin/apt-fast =>> cleanstart.sh: line 134: sudo: command not found" that's why I did this basic question.
    – Roger
    Aug 9, 2011 at 19:33
  • That's odd. The error message seems to indicate that sudo can't find the chmod command. Unless the command in the script is sudo "chmod +x /usr/bin/apt-fast", which would cause sudo to look for a command named "chmod +x /usr/bin/apt-fast". (But in any case, you don't need sudo inside the script.) Aug 9, 2011 at 19:49
  • 1
    I see from your other question that your script had clobbered $PATH. Aug 9, 2011 at 20:30

2 Answers 2

4

No. the command will be run with root privileges and all commands that the script runs will inherit the privileges.

-1

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.

1
  • You're not running in any sort of "kernel mode". You're just running it as a user with elevated permissions.
    – Wuffers
    Aug 21, 2011 at 2:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .