Operations 5 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Quickly Identify Which Process Is Using a Specific Port on Linux

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 80

lsof 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:80

fuser command

fuser

shows 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 -v

nmap tool

nmap

can 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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxnetstatlsofnmapssfuser
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.