PCP script to find open TCP ports and PIDs related in Solaris

PCP is a very useful security and adminitration script that can help you quickly find Processes (PIDs) having particular TCP Port(s) open, TCP ports open by specific PIDs or even list all the TCP Ports open by all PIDs running on your system.


The PCP script works on Solaris 10/9/8 and can be downloaded from here. Simply save the pcp.txt file to your Solaris Server as a Shell scripts (say pcp.sh) and change permissions to execute.

# chmod 755 pcp.sh

PIDs for TCP Port

Run PCP with “-p” option to show the PIDs of processes having a TCP port (say Port 22)

pcp1

For instance, to find PIDs opening TCP port 22.

TCP Ports open by PIDs

Run PCP with “-P” option to show the TCP ports open by specific PID

For instance, here I try to find the TCP ports open by PID 18805

pcp3

All PIDs for all open TCP Ports

Use the “-a” option to list all TCP ports open with all the PIDs

pcp2

5 thoughts on “PCP script to find open TCP ports and PIDs related in Solaris”

  1. WARNING – WARNING – WARNING

    You must NEVER use this tool on a production system. Like most lsof-like scripts for Solaris you can find on the net it is based on the Solaris pfiles command. This command temporarily stops the process in order to inspect it. For some processes/daemons even a short stop will make them crash. Don’t go there, amigo.

Leave a Comment

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