Install lsof on Raspberry Pi

Install lsof on Raspberry Pi

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 -v

Execute the lsof command without any arguments in order to get a list of all files that opened by processes:

sudo lsof

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:

An opened files by processes that owned by specific user

If lsof is no longer needed, you can remove it with command:

sudo apt purge --autoremove -y lsof

Leave a Comment

Cancel reply

Your email address will not be published.