PDA

View Full Version : How to control what user a program runs as


JBR
12-29-2002, 08:18 PM
Linux Question:
This seems to be obvious to everyone because I can't seem to find any documentation on it, but how do you know what user a program ( i.e. Apache, Mysql ) is running as and how do you change it?

Sorry if this is obvious I just can't seem to find anything about it. Everyone talks about making sure that these and others aren't running as root but no one mentions how to do that.

Thanks in advance.
JB

bcarl314
12-30-2002, 01:50 PM
Drop down to the command line and try this

ps waux | grep "Apache" | more

It should tell you the process ID for Apache and who the owner of that ID is. Change to mySQL for mySQL.

To change which users have access to it, you'll need to use chmod and chgrp.

for more info on those type
man chmod
and
man chgrp

you'll probably want chmod to 770

I think Apache is usually run by root, so you'll need to change the group to the one you want, and make sure the right people are in that group.

Hope this helps.

JBR
12-31-2002, 06:39 AM
Thanks for your reply but maybe I didn't ask this right. You mentioned that Apache is usually run by root. Is that the same as running Apache as user root? I've heard (read more like) that you shouldn't run Apache as user root, you should run Apache as another user like "apache" and then chown your webroot directory to apache user & group, that way apache has control over the webroot but not outside of it for security reasons. At least this is how I've understood what I've read in the past, maybe misunderstood is a better word.
But if I have understood it correctly then how do you change Apache so that it doesn't run as root but as some other user.

I hope I'm not to far off the mark on this <g> I've been around Linux awhile but still got alot to learn as you can see.

Thanks again.
JB

bcarl314
12-31-2002, 12:27 PM
Yes, when I say root, I mean the root user, or system administrator login. And yes your in the right track. You need to use chown (not chgrp) to change the owner for a file.

JBR
12-31-2002, 03:43 PM
Ok, I think I follow you.

Thanks
JB