This question already has an answer here:
I have a directory in my home-directory, which I share with a UNIX-group, but now want to delete.
If there is a file owned by an other user in this directory, I can remove it with rm, because the directory is owned by me. Not so with sub-directories, which are owned by other users. I can not delete them with rm -rf or rmdir.
me@unix:~/blub.git$ ll total 3 drwxrwxr-x 5 me collab 5 Nov 30 13:32 objects me@unix:~/blub.git$ cd objects/ && ll total 8 drwx------ 2 bob collab 3 Nov 30 13:31 bb drwx------ 2 bob collab 3 Nov 30 13:31 cf drwx------ 2 bob collab 3 Nov 30 13:32 e6 me@unix:~/blub.git/objects$ rm -rf bb rm: cannot remove `bb': Permission denied
How do I get rid of this shared folder anyway? Without help from root or the other user?
Or to ask the question in an other way: How can I really rmdir a not-empty directory without having to recursively rm -rf all the stuff in it?
To delete a directory (with rm -r), one must delete all of its contents recursively. This requires that one must have read and write and execute permission to that directory (if it's not empty) and all non-empty sub-directories recursively (if there are any). The read permissions are needed to list the contents of the directory in order to delete them. This sometimes leads to an odd situation where a non-empty directory cannot be deleted because one doesn't have write permission to it and so cannot delete its contents; but if the same directory were empty, one would be able to delete it.
Is this really true?