UNIX: List open files


Can’t eject a CD or unmount an external hard drive on your mac because of this error: The disc is in use and could not be ejected. Try quitting applications and try again.?

This UNIX command reports a list of all open files and applications that opened them. Open Terminal and replace the name of your volume below to test.

$ lsof | grep /Volumes/media/

Thanks

Addendum: Here’s an even more helpful command: eject the disk with UNIX when the GUI won’t allow it.

$ diskutil eject [Mount Point|Disk Identifier|Device Node]

Oh, and a final tip nestled in this addition: If you have a space in the name (for example you had two disks mounted named “backup” and OSX named the second one to mount “backup 1”) then you can easily reference the name (or any file or directory name with a space) with a backslash which “escapes” the character. Typing the first few characters and then type the tab key will do it automatically.

$ diskutil eject /Volumes/backup\ 1/

-->