1

Say I have normal 15 user groups and 1 admin group. I have a file directory /ReadingMaterial which has 15 text files inside of it. I want the admin group to have read/write permissions to the entire directory (all 15 files). I want the user groups to only be able to read 1 specific file inside the directory. For example, UserGroup1 will only have read access to the file called UserGroup1Material.txt

I can't find the command required tho anywhere with searching, found dozens of pages which go over simply creating or editing groups and files as a whole (owners, groups, users), but none for individual groups on their own.

I'm pretty sure it can be done, but for the life of me cannot find it anywhere with google searches or in the manual

Anan
  • 81
  • 8

1 Answers1

1

You can change the group ownership of the file with chgrp and change its permission so that only the users of UserGroup1, and its creator, are allowed to have read access to your file :

chgrp UserGroup1 UserGroup1Material.txt
chmod 440 UserGroup1Material.txt
Storm
  • 717
  • 6
  • 11
  • so would be something like `chmod 000 /ReadingMaterial` to hide the directory from everyone, then `chgrp AdminGroup /ReadingMaterial` | `chmod -R g+rw /ReadingMaterials` to give the admin group read/write to all contents, then `chgrp UserGroup1 /ReadingMaterial/UserGroupXMaterial.txt` | `chgmod g+r /ReadingMaterial/UserGroupXMaterial.txt`, where X represents X usergroup? | is used to separate commands – Anan Jun 12 '20 at 16:05
  • Seems about right, as long as you have correcty set the `x` bit on the directory, otherwise you won't be able to access any of the files – Storm Jun 12 '20 at 16:24
  • would it be a better idea instead to not set it all to 000 initially and instead use g=rw and g=r ? – Anan Jun 12 '20 at 16:31
  • That could be a way to strip it off previously set permissions – Storm Jun 12 '20 at 16:32