Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 835
Nick Sergeant Avatar asked Feb 09 '09 16:02

Nick Sergeant


2 Answers

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

like image 129
Nietzche-jou Avatar answered Oct 20 '22 03:10

Nietzche-jou


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 
like image 24
Mike Avatar answered Oct 20 '22 03:10

Mike