Non Admins Running Scripts as Root

By: Benjamin Martin - Revised: 2008-06-10 richard

Have you ever wanted to have a non admin user run a script as root?  This is actually very easy to do!  It just involves adding a line to the "/etc/sudoers" file.

You need to add the following line:

"ALL ALL = NOPASSWD: /path/to/your/script"


Be very careful to get the syntax correct or you will find that the sudo command no longer works!

Once you have added this line to "/etc/sudoers" any user can do this:

"sudo /path/to/your/script" without typing in a password and without being root to begin with!  That script (or binary) will then execute with root privileges.

This handy little trick can be very useful sometimes.  For more info see see the man page sudoers ("man sudoers").