Could not remove the folder [Folder name]. Show more details Error removing file: Directory not empty Cancel-Skip All-Skip
I tried to delete these folders from terminal with:
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
I had this issue with a folder on a btrfs filesystem. Checking mount points and lsof are the normal things to look for. In my case it was corruption caused by an old bug, since fixed:
In the case of corruption where it cannot easily be fixed, the basic workaround is to back up, format the filesystem, and then restore (leaving out the bad data). Depending on how much data you have in the filesystem, this can be a chore. :-/
In my case the problem folder was inside a subvolume so I was able to do the above but by deleting only the subvolume instead of the entire filesystem. I backed up my data and deleted the subvolume: btrfs sub del <subvolume-path>. I was then able to restore into a new subvolume, leaving out the problem folder.
The cause in my case was found to be corruption of i_size, where it was non-zero. Btrfs uses the i_size to tell whether or not the folder is empty. To check on this, run:
stat -c %s <foldername>
The i_size of an empty folder in btrfs should be zero. In ext it is typically 4k.
sudo rm -rf [Folder name]
If it still displaying Directory not empty that's mean that the directory is being used. try to close it or check which program is using it then re use the command.
Worked for me when I was trying to delete Unity project and it was used by unity hub. simply closed unity hub and rewrote the command worked fine.
If you don't have write permissions set, you cannot remove the directory.
In example bellow, even though I am an owner of the directory, I cannot remove it. Once I add write permissions with
chmod - everything succeeds.
DIR:/xieerqi skolodya@ubuntu:$ ls -dl TESTDIR/ dr-xr-xr-x 2 xieerqi xieerqi 4096 Jan 24 16:06 TESTDIR// DIR:/xieerqi skolodya@ubuntu:$ rm -rf TESTDIR/ rm: cannot remove ‘TESTDIR/one & two’: Permission denied rm: cannot remove ‘TESTDIR/tom&jerry’: Permission denied rm: cannot remove ‘TESTDIR/jekyl&hide’: Permission denied rm: cannot remove ‘TESTDIR/pdfReader.sh’: Permission denied DIR:/xieerqi skolodya@ubuntu:$ chmod +w TESTDIR/ DIR:/xieerqi skolodya@ubuntu:$ rm -rf TESTDIR/ DIR:/xieerqi skolodya@ubuntu:$ echo $? 0
I have folders in Windows that are mounted to an Ubuntu VirtualBox virtual machine (VM). I could not remove them from the Windows file manager, or from inside the VM using
rm -Rf *.
TLDR: I was finally able to remove them in Git Bash (in Windows, of course), using
rm -Rf *.
When I tried to delete in Windows file manager, it said I needed Administrator priveleges to delete the folders. But, even as Admin, it still failed.
From within the Ubuntu VM (where I have never had problems removing shared files before), I got the error
cannot remove protocol error, as well as some others.
Finally, in Git Bash in Windows, I was able to delete the folders. I'm guessing that Git Bash had some sort of lock on the folders. In Git Bash, my working directory was one of the ones I was trying to delete. I backed out of it and then deleted it using
rm -Rf without any error.