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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content