Linux lsof FAQ: Can you share some examples of the Linux lsof command?
The Linux lsof command lists information about files that are open by processes running on the system. (The lsof command itself stands for "list of open files".) In this brief article I'll just share some Linux lsof command examples. If you have any questions, just let me know.
One other note: I'll also assume that you're logged in as the Unix/Linux root user. If not, you're lsof command output may be significantly limited.
Typing the lsof command by itself lists all open files belonging to all active processes on the system:
List all open files belonging to PID (process ID)
lsof -p 11925
List all open files belonging to processes owned by the user named "al":
lsof -u al
List files open in the directory specified, but don't descend into sub-directories:
lsof +d '/Users/al'
The next command lists files that are open in the directory specified, and also descends into sub-directories. Beware: this can take a very long time to run for large directory structures:
lsof +D '/Users/al'
I hope these Linux lsof command examples have been helpful. As you can see, the lsof command can be used to generate a list of open files on your Unix and Linux system with a variety of different command line options for different circumstances.
For more information on the lsof command, please see the "Related" block on this page, follow this link to lsof command search results on this website, or leave a note in the Comments section below.