lsof utility - find out what ports are listening in Linux

  • Last update: Apr 3, 2024
  • Views: 57
  • Author: Admin
lsof utility - find out what ports are listening in Linux

Colleagues hello to all.

In today's article, we'll talk about how to get information about filetypes opened by different running processes in Linux using the lsof utility. The lsof name translates as List Of Opened Files, and it is intended, as follows from names, to display open files by different processes and/or users.

 

If you don't have lsof installed, you can install it using the yum package manager.

$. yum install lsof

linux_lsof

I installed the lsof utility earlier, and Linux tells me that I already have this package installed.


 

The first use case for lsof is when run without options - lsof will print information about all running processes and all open files.

$. lsof | less

linux_lsof


 

The next option with the lsof command is to monitor the application by the listening port.

$. lsof -i :3306

linux_lsof

In this example, we are monitoring Mariadb applications on port 3306.

 

$. lsof -i :5432

linux_lsof

In this example, we are monitoring Postgresql applications on port 5432.


 

In this example, we are looking at all running processes for all users.

$. lsof -i

linux_lsof


 

In the following example, we are looking at all open files for a specific process, in this case we are looking at open files by the mariadb database process.

$. lsof -c mariadb

linux_lsof


 

Thank you all, I hope that my article helped you in some way.

 

SIMILAR ARTICLES