Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

I'm working on an installer script for the latest ATI drivers (as they are not in repo) and was wondering if I need to include sudo in the script, because it will be needed for the install.

share|improve this question
up vote 3 down vote accepted

no, if you need root privileges you call the script with sudo.

share|improve this answer
Thanks, I wasn't sure, and wanted to check before testing it :D – Chris Weigle Jan 8 '12 at 6:11
@ChrisWeigle: In general, this is correct. However, there might be cases where you want sudo in the script itself. How well this works depends on your sudo configuration, since sudo might or might ask for a password. The case I most commonly use is for editing text files. I use vim, which I call vi out of longstanding habit. On my system, vi is actually a script that runs sudo vim if the file isn't otherwise writeable. (By the way, such a script is for experienced users only, as you can break your system with it if you aren't careful.) – Scott Severance Jan 8 '12 at 22:53
I understand Scott, but, you probably also realize, as an experienced user, that is a dangerous script indeed ;) – bodhi.zazen Mar 19 '13 at 0:25

All commands in a script are run as the calling user. So if I write this script:


echo "I am running as root" > /root/status.txt

I can successfully produce a file containing "I am running as root" at /root/status.txt by executing either:

user@host$ sudo /home/user/my_script

Or as the superuser:

root@host$ /home/user/my_script
share|improve this answer

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.