A port is a logical entity which 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 list of all open ports in Linux and how to check if remote ports are reachable using ‘nc’ 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 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'