Operations 5 min read

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

This guide explains how to use Linux commands such as netstat, ss, lsof, fuser, and nmap to inspect port usage, interpret their output fields, and install missing tools, enabling you to pinpoint which processes are occupying specific ports.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Quickly Identify Which Process Is Using a Port on Linux

Linux Port Usage Inspection

Install required tools if they are missing:

yum install -y net-tools lsof psmisc

1. netstat or ss command

Using netstat: netstat -anlp | grep 8888 Option explanations: -t: show TCP ports -u: show UDP ports -l: display listening sockets only -p: show PID and program name -n: skip DNS resolution for faster output

Key columns in the output:

Proto : protocol (tcp or udp)

Recv‑Q : bytes waiting to be read by the process

Send‑Q : bytes waiting to be sent or acknowledged

Local Address : IP and port on the local machine (e.g., 0.0.0.0:22 for all IPv4, :::22 for all IPv6, 127.0.0.1:9100 for loopback only)

Foreign Address : remote IP and port

State : connection state such as LISTEN, ESTABLISHED, UNKNOWN

PID/Program : owning process ID and name

Typical state values:

LISTEN: listening for incoming connections
ESTABLISHED: active data exchange
UNKNOWN: unrecognized socket state

2. ss command

Alternative to netstat:

ss -anlp | grep 80

3. lsof command

Lists open files and the processes that own them, useful for ports:

lsof -i:80

4. fuser command

Shows which process is using a specific file or socket (ports are treated as files):

fuser 22/tcp -v

5. nmap tool

Scans local ports quickly:

nmap localhost
netstat output example
netstat output example
PID/Program column example
PID/Program column example
illustration
illustration
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.

Linuxnetstatlsofnmapssfuserport monitoring
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.