0

I need to check what users php and apache are running as via SSH. I'm pretty inexperienced and can't figure out the correct command syntax to accomplish this. It seems like the grep command should work, but I haven't been able to figure it out..

Anyone know how to do this?

3
  • 2
    You are asking how to find out which users (php/apache) are logged via SSH on the server?
    – panaroik
    Sep 19, 2012 at 20:52
  • @panaroik - yes. It's my understanding that php and apache run as (potentially) separate users on the server (e.g. root, nobody, etc.) and I need to check and see what they are running as (via Putty).
    – Nate
    Sep 19, 2012 at 20:53
  • What operating system? (usually ssh on MSWindows implies a POSIX compatability toolkit, but not always, Apache and PHP will also run on VMS and possibly other OS too)
    – symcbean
    Sep 19, 2012 at 22:12

1 Answer 1

2

If I understand your question correctly. You want to find out under which users are running processes for apache/httpd when you are logged in on the server using Putty (using SSH)?
Well you can list all running processes and grep either apache/httpd like this:

ps -ef | grep -e apache -e httpd

I am not sure which distribution you are running, but apache is mostly running by user www-data. Here is example from my server:

root@root:~# ps -ef | grep -e php -e apache -e www | grep -v grep
www-data  9388 26594  0 22:20 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 14836 26594  0 22:27 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 16862 26594  0 21:27 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 18887 26594  0 21:57 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 20466 26594  0 21:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 22832 26594  0 21:34 ?        00:00:00 /usr/sbin/apache2 -k start
root     26594     1  0 Sep14 ?        00:00:08 /usr/sbin/apache2 -k start
www-data 30217 26594  0 21:42 ?        00:00:00 /usr/sbin/apache2 -k start

Correct me if this is not what you were asking.

1
  • ps -ef | egrep '[p]hp|[a]pache|[h]ttpd'.
    – quanta
    Sep 20, 2012 at 2:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .