I know there is the +i flag for files and directories, but i have a deeper Problem.

Is there a way to prevent a folder from being deleted by an User which should be able to create / access / remove files and folders INSIDE the delete-protected folder?

The sudo chattr +i testfolder flag wont help because then a user can only read files, but not create or delete these.

The sudo chattr +a testfolder flag wonth either help because then a user can write and read files, but only append edit files and dont remove them.

I need a solution where a user is able to write, access and remove Files but can't delete the root/parent folder.


The deletion of a directory depends on the rights of its parent directory and not its own rights. If the user have write permission to the parent, then the directory is deletable, otherwise not.

So if the user does not have to have the permission to create or delete directories/files at the same level where the directory to protect is, then this should work:

chmod 755 /the/parent/dir 

If some users still must be allowed to modify the parent's content, then the parent should be owned by a group whose members are those users and that group should have the write permission:

addgroup bigguys
chgrp bigguys /the/parent/dir
chmod 775 /the/parent/dir

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.