I have several lighttpd servers running on an Arch Linux machine, all for local network use only. I want to know which lighttpd server is watching which port. 'ps aux | grep light' lists them all by process id, but provides no clues about port number. What commands can I use to find out which process id goes with which port?
I have found a command to do the job.
ss -4 -l -p -t -n | grep light
Typical output looks like
LISTEN 0 1024 0.0.0.0:3004 0.0.0.0:* users:(("lighttpd",pid=1475828,fd=3)) LISTEN 0 1024 0.0.0.0:7880 0.0.0.0:* users:(("lighttpd",pid=252797,fd=3))
The "4" may be left off to see IPv6, but for my LAN it's all IPv4. "-l" for LISTEN, "-p" shows port numbers, "-t" for TCP (not UDP) and "-n" shows ports as numbers not meaningful names, though there probably won't be any with user-defined port numbers like 7880 set in lighttp.conf files. Grep filters the lighttpd servers (I don't care about other http servers, if any).
I have never heard of the "ss" command until recently. Maybe I should spend a day reading a Linux system administration guide - things have changed!