I have many processes on a box listening on several ports.
I am trying to map ports to pids.
The problem is that lsof is not telling me what ports belong to which process.
Given an apache listening on port 80, I can see it listening via netstat:
user@host% netstat -an|grep LISTEN|grep 80
*.80 *.* 0 0 49152 0 LISTEN
But when I try to map port 80 to a pid I get nothing:
user@host% lsof -iTCP:80 -t
When I try seeing what sockets that specific pid is using I get:
user@host% lsof -lnP -p31 -a -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
libhttpd. 31 0 15u IPv4 0x6002d970b80 0t0 TCP *:65535 (LISTEN)
Notice the *:65535 in the NAME column.
Does anyone know why lsof is not reporting the port in use?
I am running as root.
I am using a mix of lsof and os versions:
lsof v4.77 on Solaris10 sparc
lsof v4.72 on Redhat4.2
etc
I know that linux solutions can use "netstat -p",
so I guess I'm only looking for why solaris isn't working,
but I find lsof is frequently silent and not showing me expected data.
You'd rather use pfiles which is part of Solaris and supported by Sun, unlike lsof.
Its usage is slightly different as it expects a pid as argument but you can achieve what you want with something like:
or even, if you don't know the process name: