I am struggling with setting proper permissions for files example

I would like user1 and user2 have access to their directories plus shared and moderator needs to have access to all of those directories. I set private directories permissions (chmod 700 for moderator, user1 and user2 directories) user1, user2 and moderator are in the same group: shared

I thought it would be good idea to set full group permissions for shared directory, change it primary group to root and add user moderator to it but it seems not to work

Is it possible to set those permissions in simple way?

  • Primary group for shared directory is 'shared' btw not root as in example
    – squez3r
    Sep 16, 2020 at 18:34

1 Answer 1


One suggestion would be to:

  • Create a non-privileged group to use as the primary group for all user accounts involved:
    # groupadd users
  • Associate user1, user2 and moderator with this group. You may need to directly edit the password file:
    # usermod -g users user1
    # usermod -g users user2 ...
  • Change the group of all the directories in the example to be 'owned' by this group:
    # chgrp -R users * # The current working directory should be the base dir for all the
                       # directories in your example
  • Set the 'restricted deletion' and the 'setgid' bits on the 'shared' directory and allow user and group for read, write and execute:
    # chmod 3775 shared

All of the above will give all users that belong to the 'users' group, the possibility of writing files in the shared directory without being able to remove files they did not create. An alternative option would be to use a secondary group and have the users change their session group whenever they want to write in the 'shared' directory. I hope this helps, YMMV, standard disclaimers apply :)

You must log in to answer this question.