Skip to main content

lsof File Descriptor Cheatsheet

lsof (List Open Files) is an essential diagnostic tool on Linux/Unix systems for listing open files, pipes, network connections, and other resources. This cheatsheet covers basic usage, network troubleshooting, user/process analysis, and advanced techniques, including fuser and /proc filesystem utilities.

Updated: 2026-07-17·27 commands

Overview

lsof (List Open Files) is a command-line utility that lists information about files opened by processes. In Unix/Linux, everything is a file, making lsof an invaluable troubleshooting tool.

Quick Start

``bash lsof -i :80 # Find what's listening on port 80 lsof -u username # List files opened by a user lsof -p PID # List files opened by a process ``

Refer to the command table below for detailed usage.

Basic(8)

CommandLevel
lsof
List all open files on the system
Basic
lsof +D /path
Recursively list open files under a directory
Intermediate
lsof /path/to/file
Check which processes are using a file
Basic
lsof -n -P
Skip DNS and port name resolution (faster output)
Intermediate
ls -la /proc/PID/fd/
View process file descriptors via /proc
Intermediate
ls -la /proc/PID/cwd
View process current working directory
Intermediate
ls -la /proc/PID/exe
View process executable path
Intermediate
readlink /proc/PID/fd/N
Check what a specific FD points to
Intermediate

Network(8)

CommandLevel
lsof -i
List all network connections (IPv4/IPv6)
Basic
lsof -i :port
Check connections on a specific port
Basic
lsof -i :port1-port2
Check a port range
Intermediate
lsof -iTCP -sTCP:LISTEN
List all TCP listening sockets
Intermediate
lsof -iUDP
List all UDP connections
Intermediate
lsof -i @host
Filter by host/IP address
Intermediate
lsof -i -sTCP:LISTEN -n -P
Listen sockets without DNS/port resolution (common combo)
Intermediate
lsof -iTCP -sTCP:ESTABLISHED -n -P
View established TCP connections
Intermediate

User & Process(5)

CommandLevel
lsof -u user
List open files for a specific user
Basic
lsof -u ^user
Exclude files of a specific user
Intermediate
lsof -c process
Find files by process name prefix
Basic
lsof -p PID
View open files for a specific PID
Basic
lsof -p PID1,PID2
View open files for multiple PIDs
Intermediate

Advanced(6)

CommandLevel
lsof -F
Parseable output format (for scripting)
Expert
lsof | grep DEL
Find deleted files still consuming disk space
Expert
lsof -a -u user -i
AND condition combination (user and network)
Expert
fuser /path/to/file
Show PIDs using a specific file or socket
Intermediate
fuser -k /path
Kill processes using a specific file/port
Expert
fuser -v /path
Verbose mode showing process details
Intermediate

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-17.