Linux: Group permission user have read and write but can’t delete each other files

linuxpermissions

I want to create a shared folder on my Debian server so that users can create and edit files, but not be able to delete each other's files in that directory.

/home/sharedfolder

Users that can read and write files in the map are in a group: work

I tried few permission commands like these, but still not succeeding:

setfacl -dm u::rwx,g::rwx,o::r /shared/directory

How can I achieve what I want?

Best Answer

Classical solution for shared folders is sticky bit, that prevents deleting files of other users. The best example is /tmp dir.

Therefore, set the following ownership:

chown root:work /shared/directory

and permissions:

chmod 3775 /shared/directory

I'd recommend the following POSIX ACL:

setfacl -dm u::rwX,g::rwX,o::rX /shared/directory

Only users of group work can edit newly created files and dirs but can not delete the files of each other.

Related Question