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!
                    
                        Add a comment
                    
                 | 
            
                
            
        
         
    2 Answers
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}')