September 29, 2022

First of all what is a port ?

a port in networking is a software-defined number associated to a network protocol that receives or transmits communication for a specific service

netstat stands for Network statistics its a Unix-like operating system command, netstat is a command-line network utility that displays network connections for Transmission Control Protocol (TCP), routing tables, and a number of network interface and protocol statistics

if netstat is not installed by default on your OS here’s how to install it in different Linux OS:

On Debian/Ubuntu & Mint :

sudo apt-get install net-tools

On CentOS/RHEL/Fedora and Rocky Linux/AlmaLinux :

sudo dnf install net-tools

On Arch Linux :

pacman -S netstat-nat

On Gentoo

emerge sys-apps/net-tools


sudo zypper install net-tools

Once you finish the installation, you can use the netstat with grep command with pipeline between them to find the process or the service listening on a particular port in Linux

netstat -ltnp | grep -w ‘:[PORT]’

for exemple lets try the port 80 :

netstat -ltnp | grep -w ‘:80’

In this command we used options :
l – tells netstat to only show listening sockets
t – tells netstat to only display TCP connections
n – tells it to show numerical addresses
p – to show the process ID and the process name
grep -w – shows matching of exact string (:80)

And Thats it! , if you know any other ways to finding service or process listening on a particular port, let us know by a comment from below.

Leave a Reply

Your email address will not be published.