Granting 775 permissions on a directory doesn't automatically mean that all users in a certain group will gain rwx
access to it. They need to either be the owner of the directory or to 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 that's not the case, the directory's owner (alex in your example), should issue the following command:
$ 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 of alex's directories for two reasons:
- Not all of alex's directories will belong to the
consult
group
- Some of alex's directories may belong to the
consult
group but alex may not have chosen to allow rwx
group access to them.
In short, the answer depends both on group ownership and on the group permission bits set for the directory.
All of this is provided you don't use any additional mandatory access control measures on your system.
To change your default group on the fly, use newgrp
:
newgrp some_group
After running that command, you will be in a new shell with your group set to some_group
and files that you create will be in group some_group
. newgrp
may or may not ask for a password depending on how permissions are set.
Related: To find out which groups you belong to, run groups
.
Best Answer
The group entry comes from your primary group, which, by default, is the same as your username.