Find Which Process Has a File or Volume Open with lsof

List every open file descriptor — files, directories, and network sockets — per process.

macOSFilesprocesslsofDiagnosticsLow risk
Run `lsof +D /Volumes/Drive` to see every process holding files open on that volume, or `lsof -p <PID>` for one process.

01Command

Command
$ lsof +D /Volumes/MyDrive

02What 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

RiskLow risk
Requirementssudo needed to see other users' and system processes' files.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions