Find and Kill a Process
see also: 鸟哥 Linux 私房菜 Basic Linux.
Linux #
find bound PID by port: fuser 8080/tcp
kill by port: fuser -k 8080/tcp
list by port: lsof -i:8080
using netstat: netstat -nlpte |grep :8080
or: ss -nlpt 'sport = :8080'
Windows #
CMD find PID by port & kill by PID:
:: find pid first:
netstat -ano | findstr :8080
:: then the pid's task/process
tasklist | findstr "<the_PID>"
taskkill /PID <the_PID> /F
PS find for TCP & UDP:
Get-Process -Id (Get-NetTCPConnection -LocalPort <port_number>).OwningProcess
Get-Process -Id (Get-NetUDPEndpoint -LocalPort <port_number>).OwningProcess
xxx cmd list all:netstat -a -b