Find open ports in Solaris 9

In many operating systems, you can find the connection between a specific process and an open port using lsof as I mentioned here. What if you don’t have lsof, like in Solaris 9? Well, if you have pfiles, you can do the same thing by looping through the current processes and checking what port they have open:

for i in `ps -A | grep -v PID | awk '{print $1}'`; do echo PID:$i; pfiles $i | grep port; done

To break it down:

This gives you all the PIDs of running processes:

ps -A | grep -v PID | awk '{print $1}'

Loop through them with the for loop, and then print the PID and the open ports of that PID to the screen:

echo PID:$i; pfiles $i | grep port;





Please VOTE for this page at: ADD TO DEL.ICIO.US | ADD TO DIGG | ADD TO FURL | ADD TO NEWSVINE | ADD TO NETSCAPE | ADD TO REDDIT | ADD TO STUMBLEUPON | ADD TO TECHNORATI FAVORITES | ADD TO SQUIDOO | ADD TO WINDOWS LIVE | ADD TO YAHOO MYWEB | ADD TO ASK | ADD TO GOOGLE


1 Comment


  1. Make sure you have this directory in your path: /usr/proc/bin

    Posted July 9, 2009, 2:01 pm

Leave a reply