How do you set a directory to have persistent group permissions?

10,973

Solution 1

You can propagate group permissions by setting the directory's setgid bit (chmod g+s). This may not be portable across all *nixes and all file systems.

http://en.wikipedia.org/wiki/Setuid#setgid_on_directories

http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html

Solution 2

If you are using ext3 or ReiserFS, this page about creating a Linux file server may help. Specifically step 7 suggests the following command.

setfacl -d -m g:sales:rw /groups/sales 

Solution 3

I think you should look here.

As the site says, "Unix doesn't support the idea of inherited permissions."

However, there is a section on ACLs (Access Control Lists), which I think is what you are looking for. By setting up an ACL, you can have your files inherit the same ACL from the directory, which I think is what you are asking for. setfacl is the shell command that will be what you need to look into.

Hope that helps!

Share:
10,973
Nick Sergeant
Author by

Nick Sergeant

Web developer, designer, what have you.

Updated on June 17, 2022

Comments

  • Nick Sergeant
    Nick Sergeant almost 2 years

    We have two users:

    • user1
    • user2

    They both belong to the group 'admin'.

    We have a directory that has been set to 775. The directory's group has been changed to 'admin'. Each user has full access to write into that directory, though when a user writes a new file to the directory, the group permissions of the folder are not persisted to the file that was written.

    How should we make it so that files inherit the directory's group permissions?

    Clarification: when a new file or directory is written, it uses the users' group as the group of the new file, rather than that of the directory, which makes sense - but how do I not make that happen?

  • Keltia
    Keltia over 15 years
    Note that this is the SYSV compliant behaviour that you can modify by using +s on dirs. BSD behaviour has always been to have group inheritance.
  • Jonathan Leffler
    Jonathan Leffler over 15 years
    It is portable across POSIX-compliant systems, which (at least for this purpose) means anything that ends in X (Unix, Linux, MacOS X).