Mohammed Noureldin Mohammed Noureldin - 10 months ago 47
Linux Question

Is there any way to prevent different users from delete other user's files in the same share folder (but they can create own new files)?

On ubuntu I have the following:

A folder: `shares`, pemissions 755, owner root:somegroup.

Users and groups:

user1 user2 (groupx)
user3 user4 (groupy)
user5 (groupz)

I need to give the users in
the permission to create their own data inside share folder, but every single user can ONLY delete what he created, nothing more.

users can only read content of share without writing.

If that helps, may I get the answer in case of ignoring the groups (just taking care of that each single user can create, and ONLY delete his own created files)?

Can anyone help me how can I get that be giving the right permissions and owners? because nothing help came to my mind.

Answer Source

According to this topic this is not possible.

To create/remove files in some dir you need to have a wx permissions to its parent dir. The user can even delete a file that he is not able to read.

The only option I see is to create the subdirectories for each user, where only this user has write permission. (chmod 750)


It's possible! I was not aware of the sticky bit:

chmod 1770 on parent dir.

This adds a requirement that only dir owner or file owner can delete a file inside.