lsof
TLDR
List all open files
$ lsof
Files opened by user$ lsof -u [username]
Files opened by process$ lsof -p [pid]
Files using port$ lsof -i :[port]
Network connections$ lsof -i
Files in directory$ lsof +D [/path/to/dir]
Process using file$ lsof [/path/to/file]
SYNOPSIS
lsof [options] [files]
DESCRIPTION
lsof lists open files. On Unix, everything is a file including sockets and devices.
The tool shows processes using files, ports, and directories. Essential for troubleshooting.
lsof lists open files.
PARAMETERS
FILES
Specific files to check.-u USER
Files opened by user.-p PID
Files opened by process.-i [ADDR]
Network connections.+D DIR
Files in directory.-c COMMAND
Files opened by command.--help
Display help information.
CAVEATS
Requires root for all files. Output can be verbose. Performance impact on large systems.
HISTORY
lsof was created by Vic Abell in 1988 and has become a standard Unix diagnostic tool.


