2

My loacl server IP is 192.168.122.100, and remote server IP is 192.168.122.50. I need to kill all processes which connect to 192.168.122.50:56666. 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

2

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

0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.