Solaris – show listening process without lsof

netstat on Solaris lacks some of the options that linux and Windows netstat have. Most noteably, a flag that will allow you to see which process is bound to a listening network port is missing. On linux, this flag is -p and on Windows it is -b.

There are two ways to determine which binary is listening on a port on Solaris.

  1. Use `sudo lsof -i -P`. However, lsof is not installed on Solaris out of the box, so you would have to compile and install it, with dependencies if required. That can get messy. It is Solaris after all.
  2. Use the handy script called pcp:
root@solaris:~# ./pcp
usage: ./pcp [-p PORT] [-P PID] [-a] (Wildcards OK)

Running the script with -a shows all processes listening on any port, while you can filter down to just one port with -p.

Note that you need to be root or run with sudo, as a regular user does not have permissions to read some of the low level process information that is needed. I have tested this script on Solaris 10 and it works great. It does not work reliably under OpenIndiana oi_151a2, however. -a works fine, but filtering on a specific port with -p does not produce any output.

References:

PCP: http://unix.ms/pcp/

Leave a Reply

Your email address will not be published. Required fields are marked *