The lsof is a command line tool that displays information about the files opened by processes. A file can be regular file, directory, block device, network socket, named pipe, etc.
This tutorial explains how to install lsof on Raspberry Pi.
Connect to Raspberry Pi via SSH. Run the following commands to update the package lists and install lsof:
sudo apt update sudo apt install -y lsof
We can check version of lsof with command:
lsof command without any arguments in order to get a list of all files that opened by processes:
We can use
-c option followed by process name to retrieve a list of files that opened by specific process.
sudo lsof -c ssh
To get a list of files that opened by processes owned by specific user, use
-u option followed by username.
sudo lsof -u pi
Example of a part of the output:
If lsof is no longer needed, you can remove it with command:
sudo apt purge --autoremove -y lsof