"cannot remove 'some_directory': Directory not empty"
Files of the form .fuse_hidden*
are created by FUSE filesystems when a file is deleted but still in use somewhere and must still have a directory entry. This is similar to .nfs*
files on directories exported over NFS.
Run df -T .
to see the type of filesystem that's mounted on the current directory and its mount point. For an external hard disk, chances are that this is an NTFS filesystem mounted through the NTFS-3G driver, which is base on FUSE.
The name is a fake name that the filesystem driver invents for a deleted file. You can't delete the file (or rather, if you create the file, it reappears under another name). You can't delete the directory either, since it isn't empty. You'll need to find what is using this file. The most likely cause of being in use is if it's open by some application. Run lsof /media/mount-point
where /media/mount-point
is the filesystem mount point and look for an open file in that directory.
Hidden Files
You may have hidden files. You can find them with ls -la
to make sure you're okay with really deleting them first. Then you can delete the files before running rm -r
or rmdir
as needed.
Forcing the Recursive Delete
You can also just do rm -rf
to force the recursive deletion even if the target directory contains files. All the usual warnings apply, but it will get the job done regardless of what your directory contains--as long as you have permissions to delete the files and directories, of course.
For external hard disks this problem could be resolved by,
- Right Click on the folder and select
Move to Trash
- Empty the Trash
It worked for me even if rm -rf
didn't work.