There are various methods to find out your Apache web-server user or group name who is running httpd server on Linux operating system.
lsof command
Run the following command:
lsof -i lsof -i | less lsof -i | grep :http
Sample outputs:
apache2 4122 root 4u IPv6 32570 0t0 TCP *:http (LISTEN) apache2 4125 www-data 4u IPv6 32570 0t0 TCP *:http (LISTEN) apache2 4126 www-data 4u IPv6 32570 0t0 TCP *:http (LISTEN) apache2 4127 www-data 4u IPv6 32570 0t0 TCP *:http (LISTEN) apache2 4128 www-data 4u IPv6 32570 0t0 TCP *:http (LISTEN) apache2 4129 www-data 4u IPv6 32570 0t0 TCP *:http (LISTEN)
Where,
- apache2 (1st column) – Apache service / server name
- 4122 (2nd column) – Apache server PID
- www-data (3rd column) – Apache server username for PID. This gives you apache username.
httpd.conf file
Another method is to go through config file httpd.conf and find out user and group name:
egrep -iw --color=auto 'user|group' /etc/httpd/conf/httpd.conf egrep -iw --color=auto '^user|^group' /etc/httpd/conf/httpd.conf
Sample oututs:
User apache Group apache
ps and grep command
Type the following command:
$ ps aux | egrep '([a|A]pache|[h|H]ttpd)'
OR
$ ps aux | egrep --color '([a|A]pache|[h|H]ttpd)'
Sample outputs:
Fig.01: Finding out what user Apache is running as using ps command
ps aux | egrep '([a|A]pache|[h|H]ttpd)' | awk '{ print $1}' | uniq | tail -1
Sample outputs:
www-data
Using apachctl command for finding out what user Apache is running as?
Type the following command
apachectl -S
Sample outputs:
VirtualHost configuration:
*:80 nas01.nixcraft.net.in (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.
🐧 2 comments so far... add one ↓
🐧 2 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
thank you! This was the final step I needed
You are really doing a great job here man, thumbs up to you