2009-08-11

Find the files and socket opened by a process

#pfiles PID

Which will list all the files and sockets opened by this process.

If you have a port number and would like to know which process is using it, and you don't have a lsof installed, here is a short script to find it.

for i in `ps -ef -o pid | grep -v PID'`
do
pfiles $i | grep $PORTNUMBET && echo && echo "PID $i is using port number $PORTNUMBER." && echo && pfiles $i
done


#Basicly, this script run command pfiles command agains all running process and search for the process with the port opened.

No comments: