The lsof is a command line tool for showing information about files that are currently opened by various processes running on the system. It can be a regular file, directory, block device, network socket, named pipe, etc.
This tutorial shows how to install lsof on Ubuntu 22.04.
Update the package lists:
sudo apt update
Run the following command to install lsof:
sudo apt install -y lsof
Check lsof version:
To get a list of all files that opened by processes, run the
lsof command without any arguments:
-c option can be used to specify process name to retrieve a list of files that opened by a specific process.
sudo lsof -c ssh
To get a list of files that opened by processes owned by a specific user, use
-u option followed by username.
sudo lsof -u adminer
If lsof is no longer required, remove it using the following command:
sudo apt purge --autoremove -y lsof
Leave a CommentCancel reply