running app as different user
Ghodmode
ghodmode at ghodmode.com
Wed May 2 12:57:14 UTC 2007
On 5/2/07, Paul Kaplan <pkaplan1 at comcast.net> wrote:
>
> I know how to run applications w/ root privileges using sudo, but how can
> I
> run an application as a different normal user?
> Paul
>
Hi Paul,
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: man chmod or
http://www.die.net/doc/linux/man/man1/chmod.1.html). Using this method, you
don't need to type any passwords.
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:
sudo chown user2:user2 /usr/bin/foo
Then you'll want to set the setUID and setGID bits with chmod:
sudo chmod ug+s /usr/bin/foo
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.
-- Vince
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20070503/d36761ab/attachment.html>
More information about the ubuntu-users
mailing list