My loacl server IP is, and remote server IP is I need to kill all processes which connect to By executing ss comand, I found there are three TCP connections has been established. But I don't konw which process are using these sockets. How can I find out the PID of these socket?
Thank you in advance!

2 Answers 2


Using lsof command. Usage:
sudo lsof -ni tcp | grep <port>
And the 2nd column is PID.


This is for modern Linux'es:

kill $(sudo netstat -n -eep | awk '/IP_ADDRESS:PORT.*ESTABLISHED/{print $9}' | awk -F / '{print $1}')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .