Using lsof, I can find all of the processes with a TCP socket listening for connections:
lsof -Pni -sTCP:LISTEN
e.g.:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
cupsd 662 root 7u IPv6 11108 0t0 TCP [::1]:631 (LISTEN)
cupsd 662 root 8u IPv4 11109 0t0 TCP 127.0.0.1:631 (LISTEN)
rsyncd 905 root 4u IPv4 13379 0t0 TCP *:873 (LISTEN)
...
Is there any way (without piping the output to another program, like grep, awk, or sed) to limit this to TCP sockets listening on the wildcard address? Tried:
$ lsof -Pni @0.0.0.0 -sTCP:LISTEN
lsof: incomplete Internet address specification: -i @0.0.0.0
and
$ lsof -Pni @\* -sTCP:LISTEN
lsof: unknown host name (*) in: -i @*
Alternatively, is there any way to generically negate the conditions passed to lsof?