Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Users and Permissions File Ownership

Permissions for different groups.

How could I set different permissions for different users and groups for the same file? Now what I see that we can only set permissions for the one user and one group For example in Windows we are able to set any kind of permissions for any number of users for the same file or folder. What is the solution for that in Linux?

Thanks!

4 Answers

ywang04
ywang04
6,762 Points

To meet your requirement, what I thought is ACL(Access Control Lists). This provides additional permission mechanism for file systems and allows you to give permissions for any user or group to any disc resource.

But by default there is no such a mechanism? Right?

ywang04
ywang04
6,762 Points

Yes, default mechanism has limitations.

ywang04
ywang04
6,762 Points
-rw-r----- 1 treehouse treehouse  342 Jul 25 00:03 hello.txt

For instance, we have one file named hello.txt. The owner of this file is "treehouse" which belongs to group "treehouse" as well. The group "treehouse" also has other users like "test1", "test2".

  1. The owner "treehouse" has read and write permissions(-rw-r-----) for hello.txt.
  2. "test1" and "test2" belong to group "treehouse" only have read permission(-rw-r-----) for hello.txt.
  3. Other users which are not "treehouse", "test1" and "test2" don't have any permissions (-rw-r-----) for hello.txt

Hope this helps.

Yes, I understand that. But how to give rights for read and write not only to "treehouse" group but also to say "treebears" group members, while keeping all the others have no permissions?

  1. The owner "treehouse" has read and write permissions(-rw-r-----) for hello.txt. 2."test1" and "test2" belong to group "treehouse" only have read permission(-rw-r-----) for hello.txt.
  2. All members of "treebears" group have RW access for hello.txt.
  3. Other users don't have any permissions (-rw-r-----) for hello.txt
ywang04
ywang04
6,762 Points

The precondition is the owner of this file is treehosue and treehouse belongs to treehosue group for "hello.txt". And then you introduced a new group treebears.

May I know your assumption?

  1. Does the owner user treehouse belong to treebears?
  2. Or treebears is just an independent group, which doesn't have any relationship with owner treehouse?

"treebears" is independent group. I mean a situation like that:

  • we have a folder in our network where many depatments of my organiztion should have access to.
  • deparment members are included in threr own security group.
  • definite subset of deparment groups should have access to the same folder.

How to define permissions for the folder correctly?