lsof

CLI

List open files and the processes that opened them.

1 views

Installation

Homebrewbrew install lsof
aptsudo apt install lsof

Links

License

SMAIL

AI Agent Notes

Find which process has a file or port open

When to use

Debugging 'port in use' errors or finding processes holding files

Examples
  • lsof -i :3000 # what's using port 3000
  • lsof -p 1234 # files opened by PID
  • lsof /var/log/app.log # who has this file open

Proven Recipes

Find process using a port🟢 99% success
lsof -i :PORT -sTCP:LISTEN