Site TIPS PAGE🔎   UP ONE LEVEL
 OJB's Web Site. V 2.1.tip tips mac owen2 
Tip

Up to OJB's Mac Tips List

List Files Open on a Volume

A common problem is that when trying to eject a disk, flash drive, or other storage device, you are told it cannot be done because "one or more programs may be using it". Of course, you can just go ahead and unplug the disk anyway, but then the computer will warn you about that. Is there a way to tell what might be open on the disk?

There is a command line utility called "lsof" (list open files) which will list all the files the system has open. To show only those on a certain device, use the grep (global regular expression parser) command to show only those on the disk you are interested in. The command is this:

lsof | grep /Volumes/DISKNAME

Where DISKNAME is the name of your disk. If the disk has a space in its name remember to "escape" it using \, like this: /Volumes/Macintosh\ HD, or put it in quotes like this: "/Volumes/Macintosh HD". /Volumes is the folder where the Mac stores all the connected storage devices.

The "|" symbol is called a pipe and it takes the output of one command (lsof, which lists all the open files) and sends it to the input of another command (grep, which filters the text sent to it), a very powerful feature of Unix!



My latest blog post: Manufactured Outrage: We might be beginning to win some battles, but the war is far from over. (posted 2024-12-17). My latest podcast: OJB's Podcast 2024-12-04 Avoid Microsoft.
 ©2024 by OJBServerMS Free ZoneMac Made
T: 11. H: 203,746,080
Features: RSS Feeds Feedback LogMod: 07 Jun 2024