How to Quickly Identify Which Process Is Using a Port on Linux
This guide explains how to use netstat, ss, lsof, fuser, and nmap commands on Linux to list open ports, interpret their status columns, and determine which processes are occupying specific ports, with installation tips and example outputs.
Checking Port Usage on Linux
1. netstat or ss commands
Install the required tools if they are missing: yum install -y net-tools Use netstat to display listening sockets and the owning processes: netstat -anlp | grep 8888 Key netstat options:
-t : show TCP ports
-u : show UDP ports
-l : display only listening sockets
-p : show PID and program name
-n : show numeric addresses without DNS lookup
Explanation of the output columns:
Proto : protocol (tcp or udp)
Recv-Q : receive queue size; non‑zero may indicate a DoS attack or backlog
Send-Q : send queue size; non‑zero may indicate slow remote receiver
Local Address : IP and port the socket is bound to (e.g., 0.0.0.0:22, :::22, 127.0.0.1:9100)
Foreign Address : remote endpoint of the connection
State : connection state such as LISTEN, ESTABLISHED, UNKNOWN
PID/Program : process ID and program using the socket
2. ss command
ssprovides similar information with a faster implementation:
ss -anlp | grep 803. lsof command
List open files and the processes that own them, including network sockets:
yum install -y lsof lsof -i:804. fuser command
Show which processes are using a specific file or socket. For example, to check port 22:
yum install -y psmisc fuser 22/tcp -v5. nmap tool
Scan local ports quickly:
nmap localhostSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
