How do I setup a shared folder / common used folder under linux with standard linux permissions? My requirements are:

  • Only specified users have write permissions.
  • If a user writes a folder other write enabled users shall be able to edit them. (It shall be irrelevant who created a file - the other user shall be able to edit them.)

My first try was a group named shared_data and one user and the group owns the directory with ls -l giving

drwxrwxr-x   2 user   shared_data  4096 Nov  8 18:11 shared_data

but if user creates a folder it belongs to the group user and not to the group shared_data.

user@shared_folder$ touch test
user@shared_folder$ ls -l
-rw-rw-r-- 1 user user 0 Nov  8 18:16 test

According to this, you want to set the setgid bit on the directory:

$ chmod g+s shared_data

All new files created in the directory will have the group set to the group of the directory.

  • I created a subfolder with userA and it worked that it now belongs to group shared_data but userB (also in this group) can't write files in the subfolder.
    – pirad
    Nov 8 '17 at 19:06
  • 1
    My problem was that I had to login with each user after adding him to the group.
    – pirad
    Nov 8 '17 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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