1

If user A is member of group foo, is it then possible for A to share a file for all members within foo without root permissions?

chown foo:foo file 

Is not permitted without privileges.

A can say

chmod o+rw file

but if A do not want to make it public for other users than those within foo, that does not work.

2 Answers2

4

I found that the command chgrp does the trick:

chgrp foo file
1

You can create a directory for the group where you want the shared files to live.

Then, you can set setgid bit on the directory, which forces all newly created files to inherit the group from the parent directory. This way you don't need to chgrp the files.

So, for example:

mkdir /shared
chgrp sharegroup /shared
chmod g+swr /shared

Now, if any user creates a files in /shared, its owner will be that user and group will be sharegroup.

You also need to make sure that the default umask for users is 0664, which means group members can write to files too.

  • This solution is better than having to change the group for every file. If the user moves the file to the shared directory he probably intended to share it. – user877329 May 05 '14 at 15:12