How to Quickly Identify Which Process Is Using a Specific Port on Linux
This guide explains how to use Linux commands such as netstat, ss, lsof, fuser, and nmap to list open ports, interpret their output fields, and pinpoint the processes that are occupying particular ports on a server.
Netstat and ss commands
Both netstat and ss can display listening sockets and the processes that own them. Install the required tools if they are missing (e.g., yum install -y net-tools for netstat, yum install -y iproute for ss).
Example using netstat to find processes listening on port 8888: netstat -anlp | grep 8888 Key options: -t: show TCP ports -u: show UDP ports -l: show only listening sockets -p: display PID and program name -n: show numeric addresses (skip DNS lookup)
Typical columns in the output:
Proto : protocol (tcp or udp)
Recv-Q : bytes waiting to be read by the local process
Send-Q : bytes waiting to be transmitted
Local Address : IP and port on the local host (e.g., 0.0.0.0:22 for all IPv4 interfaces, :::22 for all IPv6 interfaces, 127.0.0.1:9100 for loopback only)
Foreign Address : remote endpoint (same format as local address)
State : connection state such as LISTEN, ESTABLISHED, or UNKNOWN PID/Program : process ID and the executable using the socket
To achieve the same with ss:
ss -anlp | grep 80lsof command
The lsof utility lists open files and the processes that opened them; network sockets are treated as files. Install it if necessary ( yum install -y lsof).
lsof -i:80fuser command
fusershows which processes are using a specific file or socket. Install it via yum install -y psmisc. Example to check which process owns TCP port 22:
fuser 22/tcp -vnmap tool
nmapcan scan local ports quickly. No extra installation steps are shown, but the basic usage is: nmap localhost Reference link: https://www.cnblogs.com/myitnews/p/11516730.html
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
