Is there any way to grant writing permission to a group?

I have two users ( alex and ben ).

alex is member of group alex and of group consult .

ben is member of group ben and of group consult .

I want to grant read-write access to both alex and ben on the folder consult_documents .

If I make alex the owner of the directory consult_documents and I grant 775 access to the directory consult_documents , ben and alex will be able to access the folder, I think.

But will this allow ben access to alex's other folders as well? If a user is in two groups, does that mean that all the members from both groups get the same permissions on all folders?

Best Answer


Granting 775 permissions on a directory doesn't automatically mean that all users in a certain group will gain rwx access to it. They must either be the owner of the directory or belong to the directory's group

$ ls -ld some_dir
drwxrwxr-x 2 alex consult 4096 Feb 20 10:10 some_dir/
              ^     ^
              |     |_____ directory's group
              |___________ directory's owner

So, in order to allow both alex and ben to have write access to some_dir , the some_dir directory itself must belong to the consult group. If this is not the case the directory owner alex should issue the following command in your example

$ chgrp consult some_dir/

or to change group ownership of everything inside the directory.

$ chgrp -R consult some_dir/

This will only work if alex is a member of the consult group, which seems to be the case in your example.

This will not allow ben to access all alex's directories for two reasons

  1. Not all of alex's directories will belong to the consult group
  2. Some of alex's directories may belong to the consult group but alex may not have chosen to allow rwx group access to them.

The answer depends both on the group ownership and group permission bits for the directory

All of this is provided you don't use any additional mandatory access control measures on your system.