Find Which Process Has a File or Volume Open with lsof
List every open file descriptor — files, directories, and network sockets — per process.
01Command
$ lsof +D /Volumes/MyDrive02What it does
macOS refuses to eject a disk or empty a file while any process holds it open, and lsof names the holder exactly. +D scans a directory tree but can be slow on big volumes; `lsof <path>` is the faster single-path form. On the network side, `lsof -i :443` shows which process owns each connection, making lsof a dual-purpose file and socket tracer.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- macOS lsof — list open filesEvidence: Documents lsof +D directory scanning, -p PID filtering, and -i socket filters.
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
List the biggest files in your home folder that are eating disk space.
Make Finder display .pdf, .docx, .png and every other extension at all times.
Erase the broken Spotlight database so macOS re-indexes your drive from scratch.