Sunday, December 20, 2009

Finding open files on a Mac: lsof

If you want a way to find open files on a Mac, you can use the "lsof" command at the terminal (located: /usr/sbin/lsof). Open Terminal (under Applications | Utilities) and type:

lsof | more
This will list all open files and be a long list. To restrict the list, say, to all files on mounted volumes, use grep:

lsof | grep "Volumes"
I wanted an alternative to the useful windows "handle" command-line utility to locate open file handles. The new Snow Leopard finder tells you what program has open files on a mounted volume, but earlier versions of Mac OS/X won't.

The application name is the first item in the list and the file is the last.

No comments: