How do I run a script as a certain user when it is called by another user with sudo?

Updated -

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 permissi...

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.