Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I call a bash script with sudo, for example:

sudo bash

Do I still have to use sudo inside the script in cases like this:

sudo apt-get update

share|improve this question

migrated from Aug 9 '11 at 21:52

This question came from our site for professional and enthusiast programmers.

Did you try it? – Cfreak Aug 9 '11 at 19:15
Course. I am getting a strange error: "+ sudo chmod +x /usr/bin/apt-fast =>> line 134: sudo: command not found" that's why I did this basic question. – Roger Aug 9 '11 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.) – Keith Thompson Aug 9 '11 at 19:49
I see from your other question that your script had clobbered $PATH. – Keith Thompson Aug 9 '11 at 20:30
up vote 4 down vote accepted

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

share|improve this answer

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.

share|improve this answer
You're not running in any sort of "kernel mode". You're just running it as a user with elevated permissions. – Wuffers Aug 21 '11 at 2:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.