Find and Kill a Process

Find and Kill a Process

2021-10-09. Category & Tags: Windows, linux, Commands, Networking, Ports

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'

ref 1 & ref 2

Windows #

CMD find & kill by PID:

netstat -ano | findstr :8080
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