Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Looks like a bug in lsof to me! –  Celada Feb 3 '13 at 22:01

1 Answer 1

Do you have to use lsof?

netstat -tulpn will show the processes that are listening on any given port. Processes listening on all IPs will show as 0.0.0.0:

share|improve this answer
    
But this command shows also processes which listen on a specific IP, like lsof -Pni -sTCP:LISTEN?! –  mpy Jun 29 '13 at 14:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.