Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

small tip - Which applications are using a given directory

Date: 2009-01-03 00:00:00 -0400

If you ever need to know which application(s) are using (writing or reading) a given directory on your disk, lets say because it is a usb memory stick that you need to unmount and you cant because you do not know which application is still using it.

And the Operating system says that the unit is busy

This is what happens when I try to unmount it

sudo umount /media/usb

umount: /media/usb: device is busy

Use this command.

lsof +D /media/usb

This is the output for me.

COMMAND  PID    USER   FD   TYPE DEVICE  SIZE NODE NAME
COMMAND  PID    USER   FD   TYPE DEVICE    SIZE NODE NAME
bash    5581 ggarron  cwd    DIR   8,49   32768    1 /media/disk/
evince  6991 ggarron   15w   REG   8,49 1496960  323 /media/disk/BA1000_MSAG Brochure_Spanish.pdf

This is because I cd to /media/usb/ from another terminal window, and also opened a .pdf file.

So you can see that bash and evince are using that directory, now I can close or kill them, and I will be able to unmount the usb memory.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.