A Linux system administrator needs to know some Linux commands. Join us to learn How to Find Out Which Process Listening on a Particular Port. But first, let’s know about the Port basically. 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. To let your studies work better, choose your own VPS Server with instant activation.
Table of Contents
How to Find Out Which Process Listening On A Particular Port
Recently, we explained how to find out list of all open ports in Linux. Join us with this article to see 3 different ways of finding the process/service listening on a particular port in Linux.
netstat 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 yum install net-tools #RHEL/CentOS $ sudo apt install net-tools #Debian/Ubuntu $ sudo dnf install net-tools #Fedora 22+
Once installed, you can use it with 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 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 yum install lsof #RHEL/CentOS $ sudo apt install lsof #Debian/Ubuntu $ sudo dnf install lsof #Fedora 22+
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. Let’s see what is the third and last way of finding Out Which Process Listening On A Particular Port.
You can install it as follows:
$ sudo yum install psmisc #RHEL/CentOS $ sudo apt install psmisc #Debian/Ubuntu $ sudo dnf install psmisc #Fedora 22+
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=
Conclusion
In this article, you learned How to Find Out Which Process Listening On A Particular Port. So choose a suitable way between 3 suggestions in this guide. Trace Linux commands to find more useful articles.
Many thanks. Could you please say how to find out which process is listening on a port on Mac?
Yes, sure. You need to use lsof command to find the process ID and use the ps command to show the name on Mac Os X.
What’s the way of finding a port number on Mac?
Follow the below path to find it.
• Launch System Preferences
• Go to Network > Advanced
• Click the Port Scan tab and enter the IP address you wish to scan
I need to find out that which process is using port 8080.thank you
To do this, you need to use Windows netstat command to help you identify which applications are using port 8080.
Then, follow the below path:
1. Hold down the Windows key and press the R key to open the Run dialog.
2. Type “cmd” and click OK in the Run dialog.
3. Verify the Command Prompt opens.
4. Type “netstat -a -n -o | find “8080””. A list of processes using port 8080 are displayed.
What is netstat command?
You can use it to display network status and protocol statistics. Also, it is possible to display the status of TCP and UDP endpoints in table format, routing table information, and interface information
Is it possible to find out what app is using a port?
Yes, it is. Follow the below path:
1. Open the command prompt – start » run » cmd or start » All Programs » Accessories » Command Prompt.
2. Type netstat -aon | findstr ‘[port_number]’ . …
3. If the port is being used by any application, then that application’s detail will be shown. …
4. Type tasklist | findstr ‘[PID]’