Why do I get "Directory not empty" when I try to remove an empty directory?

I had the same problem on a external hard disk, I tried so many ways using command line, but I failed every time. That's what worked for me:

  1. Right click on folder
  2. Move to trash
  3. Empty trash

Yes, it's silly but it worked for me (I don't really know how and why, but the damned folder no longer exist)


I have win 10 + ubuntu dual system installed. And both systems share the windows parititions.

Recently, i also ran into unable to delete empty folders in those partitions under ubuntu. I can't find out solution to solve it under linux.

However, after i switch to windows, and run

chkdsk

via cmd for the target disk. Some errors checked out. and then i run

chkdsk /F

to fix disk error.

After it finish, i am able to delete those folders now.


You could delete it by typing sudo rm -rf {dir_name}. The directory might have been set to read-only permission. I hope the given command can delete the folder.


I had the same issue not able to remove directory as it is not empty.

This sequence of operations worked for me.

  1. From command line first

    sudo rmdir  --ignore-fail-on-non-empty folder-name-to-be-deleted
    

The above command helps ubuntu ignore directory is not empty.

  1. Then just go to the folder and Shift + Del. That is all.

If the directory is part of a filesystem mounted with CIFS (aka samba), and it contains a file that is a broken symbolic link, then ls fails to mention that file. (I observe this bug on a CIFS client running 14.04.2 LTS, and a server running 12.04.5 LTS.)

So the directory is not empty, but (over CIFS) you have no way to see that. The file can only be seen, and thus can only be deleted, by a command running on the fileserver hosting that filesystem.