Issue:
Administrators and engineers need to identify processes holding file locks, investigate socket activity, or troubleshoot process ID (PID) conflicts on a Linux-based system.Root Cause:
This is a reference article for thelsof utility.
Resolution:
What is lsof?
lsof lists open files on Linux-based systems. It displays information about file descriptors and the processes that hold them open, including network connections and listening ports. Use lsof to identify processes holding file locks, investigate socket activity, and troubleshoot process ID (PID) conflicts.
⚠️ Prerequisite:Basic usage Use the following commands to troubleshoot open files on a Linux system: Find all open files for a user:lsofmay require privilege elevation to access files belonging to other users. Prependsudoto any command when running as a non-root user.
Notes/Information:
lsofcan also help identify processes blocking a filesystem unmount. Runninglsof <filesystem_name>will display all open files on the named filesystem.lsof +L1can be used to find unlinked open files on local disks — files that have been deleted but are still held open by a process, which can cause unexpected disk usage.