Remove directory which is not empty in unix




















It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search. I've tried deleting a directory using "rm -rf" and I'm getting the message "Directory not empty":.

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! 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. 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. 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. Last modified on Skip to: content search login. Knowledge Base Toggle local menu Menus About the team. Knowledge Base Search. Log in. Options Help Chat with a consultant. Include archived documents.

Active 2 days ago. Viewed k times. Improve this question. Rose 2, 3 3 gold badges 25 25 silver badges 38 38 bronze badges. Mayhem Mayhem 1, 2 2 gold badges 7 7 silver badges 5 5 bronze badges. Can I ask some info about the type of files that windows alerts you about? Add a comment. Active Oldest Votes. Improve this answer. BoffinBrain BoffinBrain 5, 5 5 gold badges 30 30 silver badges 56 56 bronze badges.

I ran into a scenario where some sub directories within mydir produced the same "not empty" error. So I had to cd into mydir and perform the del on the files in each of those directories as well.

Ultimately it worked, but if I'd have had to repeat the process a third time at another sublevel, I'd have felt pretty defeated. RajnishCoder Living with Windows is basically a world of workarounds. This particular issue is nothing compared to other problems with Windows 10! I had this problem when a hidden directory or file was in the directory that I tried to delete. BoffinBrain's solution solved that. Harry Johnston Harry Johnston What the!

Having windows explorer open in a subdirectory or otherwise browsing causes this to fail twice in a row. So make sure you ask it a third time which actually worked — Jake Stevens-Haas. Actually it has occurred twice in a row for me without anything open or a permissions issue.

My record is seven times. Recommend BoffinbraiN's approach. I ran only the first command. Perfect, I was trying since half hour — trex. This found some hidden files in my folder, which then I was able to delete. Adilson Cabral Adilson Cabral 4 4 silver badges 11 11 bronze badges. This is no different to what the OP was doing.

Grisu Grisu 3 3 silver badges 7 7 bronze badges. Please write it in comment. Probably not relevant to the OPs scenario, though. Holy moly, this was literally the only think that worked of all these other solutions! Gobe Gobe 1, 1 1 gold badge 18 18 silver badges 24 24 bronze badges. Im my case i just moved the folder to root directory like so. Daniel Barde Daniel Barde 2, 4 4 gold badges 28 28 silver badges 37 37 bronze badges.



0コメント

  • 1000 / 1000