Mac os terminal delete directory not empty

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

Directory Not Empty and cannot empty Trash

I've tried doing xattr -d com. 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. 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. This should tell if any files in this directory are being used by any programmes.

Anyway, killall 1 any executables that might be using this directory or any hidden files inside it. Hope this helps. Check for any hidden and encrypted files or encryption key files in that directory. These could be the culprit. I ran into exactly this error while also trying to remove a directory rm -r dirname. I had already tried all of the suggestions I've read here before I searched and found this thread.

I do not know if there may have been any additional points unintentionally left unstated from the original question, but in my case the root of the trouble, and the solution was:. I logged into the network disk server via the ssh command and checked ls -al there. The result showed, in addition to. I believe these are, or are similar to, files which I first noted Mac OSX creating years ago when using cp -R , tar , or cpio to archive or move groups of files. I had never encountered trouble deleting these files when they had been written onto an internal, USB, or Firewire drive; this was the first time I'd found them on a network disk; completely undetectable from the client side of the mount, but normal in every way when viewed from the server side.

So, there's another answer for what it's worth; another potential solution to this problem if it should appear for anyone in conjunction with a network disk. Tried all of the answers here with no results. I was, however, able to move the directory aside using the mv command, which allowed me to continue. Beware rm -rf in such a case! It can create problems somewhere else in case it happen to be a network share! You have been warned! In nearly all cases, if a directory seems to be empty, use rmdir directory or perhaps sudo rmdir directory. Do not use rm or del under Windows. If this does not work, you need to find out, what blocks this request, fix that and then retry the rmdir.

It is very likely that the directory in question was just a mount point from the encfs or residing on a mount point which became readonly or stuck in some improper state which prevented the directory to be removed.

If you now force removal of the directory, very bad things can happen. In the good case the directory really was empty, so removing it destroying the mount etc. In the bad case it wasn't empty, just appeared to be, which means, you trashed something which you perhaps did not want to kill. This all depends on the mount type, which drivers are in use etc. If things are implemented reasonably well, normally nothing bad should happen.

However this is not the normal case. Things are in a weird state already, which means: Something is wrong, so better do not try to mix it up even further!


  1. add time in excel mac?
  2. Your Answer!
  3. Navigation menu.
  4. web development mac os x!
  5. Emptying Stubborn Files from macOS Trash.
  6. connect mac to samsung tv airplay.
  7. apache tomcat 7 eclipse mac.

If something is cracked, any wrong touch might break it. For example, if you hit a race condition on a network share, it might be that your rm -rf removes data which is just copied to the share by somebody else. However rmdir is guaranteed to never do harm, besides removing really empty directories.

1&1 IONOS Mobile App

You can detect a mountpoint using the tool mountpoint directory. Alternatively look into the output of mount and try to spot your mounts there. But beware, at least under Linux this might lie. Using the mountpoint utility more reliable but less convenient. In that case you found the mountpoint, you can unmount it and then remove the directory, this is following sequence:. Defective filesystems may deny rmdir , depending on the fail strategy.

Customizing Your Terminal: .bash_profile and .bashrc files

Perhaps you will see a reasonable message in that case, perhaps not. Under Linux and probably any modern OS you can also restrict access using different means like mounting something readonly, capabilities like in SeLinux, etc. This then means you do not see that it is a mountpoint, and you do not see anything wrong, but it just does not work. In that case you need to look for some other reason and it can be very deeply buried in the OS.

It depends on the tool if you see some reasonable error message. Note that mandatory file locking may be a source, too. While this is normal on Windows, usually it is not the normal case Unix and I never heared it for directories. Quite often in such cases, the directory in question resides on a different filesystem than which you thought. You can find out which, with the command df directory I think this is the same under OS-X.

You can inspect deeper with tools like stat or statfs on the directory. However these are a bit low level for normal people, and quite often such tools are well hidden from normal users.

rm (Unix) - Wikipedia

Directories can have files with funny names. Like a file which immediatelty erases the terminal output, so it looks like it isn't there. Try something like ls -al less or use something like MidnightCommander mc. There are trainload of other possibilites, including bugs, haxors, aliens, or perhaps more exotic things like fairies. But usually it is not wise to start looking there, instead first try to find the error at your side, because "errare humanum est". This could also be a case I just solved in which a broken symlink was on the server-side and was not visible to the client over CIFS.

The symlink populated a non-empty directory, but the client was unable to see or stat the symlink for the purpose of clearing out the directory before unlinking the directory. Since it was invisible, it created this paradox where from the client side it was empty but "not empty" upon challenge by rm. If you have SSH access to the server, try a shell on that end and see if the directory is truly empty or if it may have broken symlinks. Oct 31, 2, 2, But then again I never owned a Mac with several hard disks in one machine before until just these past 3 years.

Regardless, Mac will always rule especially when it comes to the creative arts. What happens if you remove all of the drives except for the OS drive? Given you erased the OS drive and the problem persists I would say the problem exits on one of those drives. Removing them should answer that question. If you really wish to erase a hard drive then you can use the following from a terminal window from an OS which is not booted from the hard disk in question: WARNING: This command will erase all the information on the target drive and will not be recoverable. Use at your own risk!


  1. Subscribe to RSS.
  2. canal plus a la demande plugin mac?
  3. Trash solution summary: Cannot delete files.
  4. rss reader for mac and iphone!

Jul 1, 3, 1, Vancouver Island. In Disk Utility you should be able to select the HDD's and unmount them, for all but the the boot drive. Which version of the operating system are you using? Macschrauber macrumors a. Dec 27, Germany. Had the same problem with the nul character some years ago. I remember I used an old system, afair Mar 10, 8, 1, If it is there after a clean install of the macOS you should be looking into how you've been hacked or rogue software more so than this file.

If not there on safe boot but there under a normal boot then it is some program you've installed on your system that stuff something into your folder. If you "install" is doing a backup recovery e. TimeMachine then it will come back because that's what you backed up.

Erasing is gross overkill for this problem. Way , way , way over the top and unnecessary. Trashes your machine or OS install image has been compromised. Trashes folder is the "Trash" location for the non-boot drives. If you start the system and that boot drive hasn't been mounted anywhere else by another boot drive and there is crap in the. Trashes folder something is very wrong that totally besides the file name.

Trashes folder.