Mohammed Noureldin Mohammed Noureldin - 18 days ago 7
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
groupx
and
groupy
the permission to create their own data inside share folder, but every single user can ONLY delete what he created, nothing more.

groupz
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

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)

//Edit:

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.

Comments