I have two groups "Group1" and "Group2"
I have also folder "Folder"
I want to give Group1 read and write permission , while Group2 only read .
Any suggestion ?
I have two groups "Group1" and "Group2"
I have also folder "Folder"
I want to give Group1 read and write permission , while Group2 only read .
Any suggestion ?
Let me get this straight:
You want
group1
to have read/write access to a particular folder.You want
group2
to have read-only access to that folder.You don't want
others
to have read access to that folder.By default, Linux's permission system does not allow for this. The reason is simple: for each inode there are only three bits (
rwx
) that describe permissions for a particular group, namely the group that owns the file/directory referred to by that inode. Any user who is not the owner nor belongs to that group automatically falls underothers
. In practice this is most often sufficient, but in some rare cases it may not be.The good news is that Linux actually supports ACLs (access control lists), which allow for a much more fine-grained access control. In order to enable ACLs, you have to add
acl
to the mount options. For instance, if the partition that contains the directory where you want to set up advanced access control is mounted like this in/etc/fstab
:...you would change that to:
Then you need to remount the filesystem (e.g.,
mount -o remount /dev/sda1
), or simply reboot.Next let's make sure your folder
/path/to/folder
grants read/write access forgroup1
. The permissions should look something likeAdditionally, you want to grant read access for
group2
, and no access at all forothers
. To achieve this, issue the commandThat's it. You can look into the ACL permissions of that folder later by using
getfacl
, namely:More information here: ACLs: Extended file-permissions.
These commands should work:
This will hopefully provide read & write access to the owner and the group, and read-only access to 'Others' which should include Group2.
chmod
manual page here.chown
manual page here.To reset any changes so only the owner has access, run: