lsof

List open files and the processes that own them. Great for debugging ports and file locks.

Synopsis

lsof [options]

Core Options

-i

List network files (sockets).

-iTCP

Filter TCP connections.

-p PID

Show open files for a process.

-u USER

Filter by user.

-nP

Skip DNS/port name lookup (faster).

Usage Examples

Find Process by Port

Who is using port 3000.

lsof -i :3000

List Files by PID

Show open files for a process.

lsof -p 1234

TCP Connections

Show TCP sockets only.

lsof -iTCP -sTCP:LISTEN
Built for builders.