2 Ways to Find Out Which Process Listening on a Particular Port

Created March 16, 2022

Introducton

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.


Ways

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 on Ubuntu:

sudo apt-get install net-tools

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' 

If nothing comes up, then it means nothing it listening to port on your network. If there is, you would get data about the port and more.

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

To find the process/service listening on a particular port, type (specify the port):

lsof -i :80

As again for lsof. If nothing appears after you enter the command. Nothing is listening to the port you mentioned.


Conclusion

That’s it, you have successfully learned how to find ways to find out which process listening on a particular port! If you found this usful then please share this and follow me! Also check out my Buy Me A Coffee!

Buy Me A Coffee how2ubuntu