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
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
The next option with the lsof command is to monitor the application by the listening port.
$. lsof -i :3306
In this example, we are monitoring Mariadb applications on port 3306.
$. lsof -i :5432
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
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
Thank you all, I hope that my article helped you in some way.