which user apache runs as ubntu 1

which user apache runs as ubntu

ps -ef | egrep '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

Here is what the above code is Doing:
1. ps -ef | egrep ‘(httpd|apache2|apache)’
– This will list all the processes that contain the string httpd, apache2, or apache.
2. grep -v `whoami`
– This will filter out the processes that are owned by the current user.
3. grep -v root
– This will filter out the processes that are owned by the root user.
4. head -n1
– This will only return the first process that matches the previous filters.
5. awk ‘{print $1}’
– This will print the first column of the output, which is the PID.

Similar Posts