lsof Command Examples

Lists open files and the corresponding processes. Note: Root privileges (or sudo) is required to list files opened by others. More information: https://manned.org/lsof.

lsof {{path/to/file}}

lsof -i :{{port}}

lsof -t {{path/to/file}}

lsof -u {{username}}

lsof -c {{process_or_command_name}}

lsof -p {{PID}}

lsof +D {{path/to/directory}}

lsof -i6TCP:{{port}} -sTCP:LISTEN -n -P