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 24.04.
Install lsof
Update the package lists:
sudo apt update
Run the following command to install lsof:
sudo apt install -y lsof
Check lsof version:
lsof -v
Testing lsof
To get a list of all files that opened by processes, run the lsof
command without any arguments:
sudo lsof
The -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
Output example:
Uninstall lsof
If lsof is no longer required, remove it using the following command:
sudo apt purge --autoremove -y lsof
Leave a Comment
Cancel reply