lsof
List open files and the processes that own them. Great for debugging ports and file locks.
Synopsis
lsof [options]
Core Options
-iList network files (sockets).
-iTCPFilter TCP connections.
-p PIDShow open files for a process.
-u USERFilter by user.
-nPSkip DNS/port name lookup (faster).
Usage Examples
Find Process by Port
Who is using port 3000.
lsof -i :3000List Files by PID
Show open files for a process.
lsof -p 1234TCP Connections
Show TCP sockets only.
lsof -iTCP -sTCP:LISTENBuilt for builders.