lsof

List Open Files. A powerful tool to identify which files are open by which process. In Linux, everything is a file (network sockets, pipes, etc.), making text extremely versatile for debugging.

Synopsis

lsof [options]

Core Options

-i :port

List files (network connections) on a specific port.

-u user

List files opened by a specific user.

-p pid

List files opened by a specific PID.

+D /path

Recursively search for open files in a directory.

Usage Examples

Check Port Usage

Find out what process is listening on port 8080.

lsof -i :8080

List User's Open Files

See everything 'mysql' user has open.

lsof -u mysql

Who is using this file?

Find which process is holding a lock on 'database.db'.

lsof /var/lib/data/database.db

Network Connections

List all open network connections.

lsof -i
Built for builders.