lsof
system informationLinux/Unix
The lsof command is one of the most frequently used commands in Linux/Unix-like operating systems. lsof List open files
Quick Reference
Command Name:
lsof
Category:
system information
Platform:
Linux/Unix
Basic Usage:
lsof [options] [arguments]
Common Use Cases
Syntax
lsof [options]
Options
Option | Description |
---|---|
-a |
Use AND logic between options instead of OR logic |
-c command |
Select processes with command names starting with string |
-d FD |
Select by file descriptor number or range |
-D directory |
Use this directory's contents for device cache |
-i [protocol][@host][:port] |
Select files used for Internet connections |
-l |
Don't convert UIDs to usernames |
-n |
Don't convert network addresses to hostnames |
-p PID |
Select files for process with specified PID |
-P |
Don't convert port numbers to service names |
-r seconds |
Repeat the listing every specified seconds |
-t |
Show only PIDs (terse output) |
-u username |
Select files for processes owned by user |
-U |
Show only UNIX domain socket files |
-F format |
Specify output format for processing by programs |
+D directory |
Recursively list all files in a directory |
+L |
List open files with link counts less than 1 |
Examples
How to Use These Examples
The examples below show common ways to use the lsof
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
lsof