Site TIPS PAGE🔎 SEARCH  Ξ INDEX  MAIN MENU  UP ONE LEVEL
 OJB's Web Site. Version 2.1. Mac Tip.You are here: 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!



I usually write a blog post about once a week. The latest post can be viewed here: Deranged Rants: Many of them are totally feral, unhinged, and totally irrational. (posted 2024-11-13 at 17:55:14). I do podcasts too!. You can listen to my latest podcast, here: OJB's Podcast 2024-08-22 Stirring Up Trouble: Let's just get every view out there and fairly debate them..
 Site ©2024 by OJBWeb ServerWhy Macs are BestMade & Served on Mac 
Site Features: Blog RSS Feeds Podcasts Feedback Log07 Jun 2024. Hits: 159,345,464
Description: Mac TipKeywords: Macintosh,Computers,Fixing Problems,TipsLoad Timer: 10ms