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.

  • possible duplicate of Permission denied to change gid(group) of a file I own – enedil May 4 '14 at 15:57
  • 1
    I am not really interested in why chown approach does not work. Rather, I want to create a solution for cooperative work that relies on group permissions that does not requier to much user privileges. – user877329 May 4 '14 at 16:01
  • 1
    chown foo:foo file Is not permitted without privileges. -> It's also not permitted with privileges if foo is not a group. If you want to share by changing just the group, just change the group: chown :foo file (does not require privileges). – goldilocks May 4 '14 at 16:13
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 5 '14 at 15:12
4

I found that the command chgrp does the trick:

chgrp foo file
  • 1
    This is the same as chown :foo file. – goldilocks May 4 '14 at 16:10

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.