Lsof

Open files by …

  • Pid

lsof -p <pid>
  • User

lsof -u <pid>
  • Program

lsof -c <progname>

Which command is using this port?

lsof -i :<port>

Which processes have an open TCP socket to remote-site

lsof -i TCP@remote:port

Which processes are using this file?

lsof /path/to/file

What pids does that binary have?

lsof -t /path/to/command

Find all open files in a directory

lsof +D /some/dir