Introduction
If you’re a system administrator, you know how important it is to keep track of which processes are listening on which ports. Knowing which processes are listening on which ports can help you identify potential security risks, optimize system performance, and troubleshoot network issues. In this article, we’ll discuss three ways to find out which process is listening on a particular port. We’ll cover using the netstat command, using the lsof command, and using the ss command. With these tools, you’ll be able to quickly and easily identify which processes are listening on which ports.
3 Ways to Find Out Which Process Listening on a Particular Port
1. Use the netstat command: The netstat command can be used to list all open ports and the processes that are using them. To list all open ports and the processes that are using them, open a command prompt and type “netstat -aon”.
2. Use the tasklist command: The tasklist command can be used to list all running processes and the ports they are using. To list all running processes and the ports they are using, open a command prompt and type “tasklist /svc”.
3. Use the Process Explorer tool: Process Explorer is a free tool from Microsoft that can be used to list all running processes and the ports they are using. To use Process Explorer, download and install it from the Microsoft website. Once installed, open the tool and click on the “View” menu and select “Select Columns”. In the Select Columns window, select the “Ports” option and click OK. This will display all running processes and the ports they are using.
A port is a logical entity that represents an endpoint of communication and is associated with a given process or service in an operating system. In previous articles, we explained how to find out the list of all open ports in Linux and how to check if remote ports are reachable using the Netcat command.
In this short guide, we will show different ways of finding the process/service listening on a particular port in Linux.
1. Using netstat Command
netstat (network statistics) command is used to display information concerning network connections, routing tables, interface stats, and beyond. It is available on all Unix-like operating systems including Linux and also on Windows OS.
In case you do not have it installed by default, use the following command to install it.
$ sudo apt-get install net-tools [On Debian/Ubuntu & Mint] $ sudo dnf install net-tools [On CentOS/RHEL/Fedora and Rocky Linux/AlmaLinux] $ pacman -S netstat-nat [On Arch Linux] $ emerge sys-apps/net-tools [On Gentoo] $ sudo dnf install net-tools [On Fedora] $ sudo zypper install net-tools [On openSUSE]
Once installed, you can use it with the grep command to find the process or service listening on a particular port in Linux as follows (specify the port).
$ netstat -ltnp | grep -w ':80'
In the above command, the flags.
l
– tells netstat to only show listening sockets.t
– tells it to display tcp connections.n
– instructs it to show numerical addresses.p
– enables showing of the process ID and the process name.grep -w
– shows matching of exact string (:80).
2. Using lsof Command
lsof command (List Open Files) is used to list all open files on a Linux system.
To install it on your system, type the command below.
$ sudo apt-get install lsof [On Debian, Ubuntu and Mint] $ sudo yum install lsof [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/lsof [On Gentoo Linux] $ sudo pacman -S lsof [On Arch Linux] $ sudo zypper install lsof [On OpenSUSE]
To find the process/service listening on a particular port, type (specify the port).
$ lsof -i :80
3. Using fuser Command
fuser command shows the PIDs of processes using the specified files or file systems in Linux.
You can install it as follows:
$ sudo apt-get install psmisc [On Debian, Ubuntu and Mint] $ sudo yum install psmisc [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/psmisc [On Gentoo Linux] $ sudo pacman -S psmisc [On Arch Linux] $ sudo zypper install psmisc [On OpenSUSE]
You can find the process/service listening on a particular port by running the command below (specify the port).
$ fuser 80/tcp
Then find the process name using PID number with the ps command like so.
$ ps -p 2053 -o comm= $ ps -p 2381 -o comm=
You can also check out these useful guides about processes in Linux.
That’s all! Do you know of any other ways of finding the process/service listening on a particular port in Linux, let us know via the comment form below.
3 Ways to Find Out Which Process Listening on a Particular Port
When troubleshooting network issues, it is often necessary to determine which process is listening on a particular port. This article will discuss three different ways to find out which process is listening on a particular port.
1. Using the netstat Command
The netstat command is a powerful tool for network troubleshooting. It can be used to list all the processes that are listening on a particular port. To use the netstat command, open a command prompt and type the following command:
netstat -an | find ":PORT_NUMBER"
Replace PORT_NUMBER with the port number you are interested in. This will list all the processes that are listening on that port. The output will look something like this:
TCP 0.0.0.0:PORT_NUMBER 0.0.0.0:0 LISTENING Process_Name
The Process_Name is the name of the process that is listening on the port.
2. Using the Task Manager
The Windows Task Manager can also be used to find out which process is listening on a particular port. To use the Task Manager, open it and go to the Details tab. Then, click on the “PID” column to sort the processes by their process ID. Then, look for the process that has the port number you are interested in. The process name will be listed in the “Name” column.
3. Using the Resource Monitor
The Windows Resource Monitor can also be used to find out which process is listening on a particular port. To use the Resource Monitor, open it and go to the “Network” tab. Then, look for the process that has the port number you are interested in. The process name will be listed in the “Process” column.
These are three different ways to find out which process is listening on a particular port. Knowing which process is listening on a port can be very useful when troubleshooting network issues.