<br><div><span class="gmail_quote">On 5/2/07, <b class="gmail_sendername">Paul Kaplan</b> <<a href="mailto:pkaplan1@comcast.net">pkaplan1@comcast.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I know how to run applications w/ root privileges using sudo, but how can I<br>run an application as a different normal user?<br>Paul<br></blockquote></div><br>Hi Paul,<br>    If you want to always run your program as the other user, try using the 's' attribute to set the user or group ID on execution. (ref: 
<span style="font-family: courier new,monospace;">man chmod</span> or <a href="http://www.die.net/doc/linux/man/man1/chmod.1.html">http://www.die.net/doc/linux/man/man1/chmod.1.html</a>).  Using this method, you don't need to type any passwords.
<br><br>    For example, if the program you want to use is /usr/bin/foo, first you'll want to change it's user and group to the user and group that you want it to run as:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">
sudo chown user2:user2 /usr/bin/foo</span><br style="font-family: courier new,monospace;"></div><br>Then you'll want to set the <span style="font-style: italic;">setUID</span> and <span style="font-style: italic;">setGID
</span> bits with chmod:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">sudo chmod ug+s /usr/bin/foo</span><br></div><br>    Now, whenever any user runs /usr/bin/foo, the program will be executed as if that other user was running it.  There are some minor problems with this approach.  For example, if your program starts other programs, sometimes other programs can tell who the actual user running the program is.  You might want to consider this as trial-and-error at first to see if it's the right approach for your needs.
<br><br>-- Vince<br>