Linux Commands to Check Which Process Occupies a Port

Tech Sharing 2018-04-08
Linux Commands to Check Which Process Occupies a Port

Use lsof -i and netstat -tunlp to find which process holds a port, combined with grep to quickly locate a specific port.

1. lsof -i

lsof -i shows matching processes; lsof (list open files) lists files currently open on the system. Run as root:

lsof -i:PORT

2. netstat -tunlp

netstat -tunlp shows TCP/UDP ports and processes; combine with grep for a specific port, e.g. port 80:

netstat -tunlp | grep 80

netstat checking port process