Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<  819 of 909 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 12505
Last update: 10-30-08
Issue:
How do I run a script as a certain user when it is called by another user with sudo?
Resolution:

If a script that has been written needs to be run as a particular user, the /etc/sudoers file needs to be modified to include default user options.

Edit the /etc/sudoers file by invoking:

#visudo

In this example, SCRIPT1 is the script that will be executed. TESTUSER is the alias of users who have permission to execute the script via sudo and test is the user that the script must be run as.

Cmnd_Alias SCRIPT1=/bin/blah.sh
User_Alias TESTUSER=test,test1,test2
Defaults:TESTUSER runas_default=test
TESTUSER ALL=NOPASSWD: SCRIPT1

If the sudo /bin/blah.sh command is invoked by the test, test1 or test2 users it will run as user test.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<   819  of  909  >>