Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've tried deleting a directory using "rm -rf" and I'm getting the message "Directory not empty":

Bens-MacBook-Pro:please benjaminhocking$ ls -lart empty_directory/
total 16
drwxr-xr-x  5 benjaminhocking  staff  170 Aug 27 14:46 .
drwxr-xr-x  3 benjaminhocking  staff  102 Aug 27 15:28 ..
Bens-MacBook-Pro:please benjaminhocking$ rm -rf empty_directory/
rm: empty_directory/: Directory not empty
Bens-MacBook-Pro:please benjaminhocking$ rmdir empty_directory/
rmdir: empty_directory/: Directory not empty

If I try the same thing using Finder (dragging the folder to the Trash), I get the message

The operation can’t be completed because the item “empty_directory” is in use.

I've tried doing xattr -d com.apple.quarantine, purely out of superstition, but it did no good.

A probably important piece of context is that this directory was initially in a directory that should've been deleted by a "make clean" command I issued prior to Terminal locking up on me, after which a little over half of the other programs I had running also locked up, including Skype, and eventually the OS itself. I ended up having to reboot the computer by pressing and holding the power key.

Edit to add: Another important piece of information I left off was that this was happening in an encrypted folder à la encfs. I was able to track down the corresponding folder in the encrypted side of things and delete it there. I still don't know why I couldn't do it from the decrypted side of things like I normally do. I'll leave this unanswered for now in case anyone has a good answer for that.

share|improve this question
Do you have any other shell open within this directory, or an app running just using it? The term "is in use" could also mean that (though I never experienced not being able to rmdir it -- but it often is the cause why one cannot unmount a volume). –  Izzy Aug 27 '12 at 22:44
Not at the time those particular commands had been issued. I had done a complete reboot just prior to that. –  Ben Hocking Aug 28 '12 at 13:03
I sometimes have the same problem with EncFS and so far I have no idea how to solve this. Anything new? –  Martin Preusse Oct 4 '12 at 21:34
@emempe: What I finally ended up doing was deleting the folder in the encrypted space, using the last modified timestamp as my identifier. (Which can be dangerous.) If I come up with a better solution, I'll let you know. –  Ben Hocking Oct 4 '12 at 21:42
@BenHocking: I do that too. Happens rarely for me so I'm fine with this. Still, I don't like the feeling that my EncFS got corrupted somehow ... ;) My EncFS is in a Dropbox, maybe some connection? –  Martin Preusse Oct 4 '12 at 21:49

3 Answers 3

Reboot your computer and run rmdir(1) again.

$ rmdir -r empty_directory/

If that doesn't work, then try:

$ rm -rf empty_directory/

If it still doesn't work, assuming OS X has lsof(8) preinstalled, then enter:

$ lsof +D empty_directory/

This should tell if any files in this directory are being used by any programmes. I think that the HFS+ filesystem does not allow the deletion of files in use. Anyway, killall(1) any executables that might be using this directory or any hidden files inside it. It is likely that Finder is using a hidden file in the empty_directory directory to store folder view settings. Hope this helps.

P.S.: To find out if lsof(8) is installed, enter:

$ lsof

If the output looks like this, then lsof(8) is installed on your system.

lsof: /usr/bin/lsof /usr/bin/X11/lsof /usr/share/man/man8/lsof.8.gz

Thank you for asking.

Edit: Check for any hidden and encrypted files or encryption key files in that directory. These could be the culprit.

share|improve this answer

Repairing the disk using Disk Utility fixed this problem for me.

share|improve this answer

If this happens and you're sure you want to delete everything, you should try using sudo rm -rf directory/

share|improve this answer
This does not answer the question. Please do edit your answer. –  Renju Chandran chingath Apr 1 at 4:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.