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.
Best Answer
This is basically what the /tmp folder is for. So just set the permissions that same as /tmp:
The
testfolder
should be owned by a different user (e.g. root). The user will be able towrx
files and folders under testfolder, but will not be able to remove or modify the testfolder.For example:
As you can see,
user
can create files and dirs under/test
, but is not allowed to remove it.