System

Find the number of sockets a process currently has open

To find how many sockets a process has open on Linux, follow these steps. First find the process PID with:

$ ps -aef | grep processname
pbat 4750 4437 0 07:03 ? 00:00:00 processname

Once you have the PID, use it to find the number of open sockets with:

$ ls -l /proc/4750/fd | grep -c — ’-> socket:‘
8

The command shows the number of open sockets. In this example, there are eight.

EOF.← Back to articles