I created a directory somewhere with permissions rwxrwxr-x so that other users in my group can create files and directories in it.

I do need to be able to delete the contents in this "public" directory, but it seems that while I am able to remove any files in this directory I cannot remove and subdirectories under it.

Is there a way to remove such subdirectories owned by others under a directory owned by me?

  • Are the subdirectories being created with the same permission set?
    – Fake Name
    Jul 23, 2010 at 8:43

3 Answers 3


Deleting a file (or empty directory) requires write access to the parent directory, which you have as owner.
Deleting a non-empty directory requires that you empty the directory first, which you can't do, as you don't have write access to that directory (as it was created by other users).

So you need to use sudo to get root access to delete those directories.

  • 7
    I think this points out a missing tool -- there should be some program, setuid root, that allows someone to recursively remove any directory in a directory they own. (Which should prompt for confirmation by default, include appropriate safeties, and so on.) Nov 4, 2011 at 0:10
  • @DavidSchwartz I think this is very important. sudo is not quite same because it allows user to delete anything Jun 4, 2013 at 18:14
  • @DavidSchwartz Can I upvote this 500 times? A system tool broke my home directory by putting a directory in it without adding group permissions... Let's add a feature request to... Linux?
    – ADJenks
    Nov 22, 2018 at 18:49
  • Where is the official explanation on why is it possible to delete third-party empty directories while the same is not possible for non-empty ones?. Nov 12, 2019 at 0:13
  • @JaimeHablutzel It's the consequence of two independent things really. 1. Deleting a file or directory is the modification of the containing directory, not of the file/directory that you delete. So you need permission for the containing directory only (unless sticky bit is set). 2. But, regardless of permission matters, you can't delete a non-empty directory. So it has to be emptied first, and you might not have the permission for that, but that's technically a separate operation.
    – ddekany
    May 6, 2020 at 13:58

You could add your account to sudoers and 'sudo rm -R' the folder.

I am not aware of a setting you can apply to do it normally.


logically you should if the directory is yours and is writeable. However i have heard of a subdirectory that you cannot write to preventing removing the folder/deleting files.

If you like try the command rm -f filename or rm -rf dir to remove a directory.

  • Nope, that won't work if "dir" contains files and you don't have write permission on them. See the accepted answer for details.
    – Alex
    Oct 20 at 9:26

Not the answer you're looking for? Browse other questions tagged .