Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Aug 9 '11 at 21:52

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

2  
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 =>> cleanstart.sh: 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
1  
I see from your other question that your script had clobbered $PATH. –  Keith Thompson Aug 9 '11 at 20:30

2 Answers 2

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

 
discard

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.