Using sudo in scripts

Brent Fortman Brent.Fortman at
Wed Aug 7 14:01:12 EDT 2002

No, you do not have to pre-fix every command with sudo.  Sudo <myscript>
will execute all commands in <myscript> as root.


-----Original Message-----
From: Gary Call [mailto:gcall at] 
Sent: Wednesday, August 07, 2002 11:38 AM
To: sudo-users at
Subject: Using sudo in scripts

This may sound like a basic question, but I have not been able to find
an answer anywhere.

Here is my scenario:
I need to give "userA" sudo access to a menu driven script.  The menu
driven script will execute other system commands (i.e. cpio, tar, mt).

If the user executes the script (using sudo), will all of the other
commands (cpio, tar, mt....) be executed with sudo prefixed, or will I
need to prefix every command with sudo into the script?

Any help or guidance is greatly appreciated!


sudo-users mailing list <sudo-users at>
For list information, options, or to unsubscribe, visit:

More information about the sudo-users mailing list