Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I tried finding this on here, but couldn't so sorry if it's a duplicate.

Say I have 2 groups and a user: group1, group2, user1 with the following structure: group1 is a member of group 2, user1 is a member of group1

Now say I have the following files with relevant permissions

file1 root:group1 660
file2 root:group2 660

Now when I log into user1, I'm able to edit file1, but not edit file2. Short of adding user1 to group2, is there any way of doing this? or is there no way?

I'm using Ubuntu btw.

share|improve this question
    
If I'm not mistaken, the classic group-based permissions in Linux do not allow you to put a group inside another group. So did you installed something which enables this feature? –  Gunther Struyf Sep 9 '12 at 20:47
    
A User can be a member of several groups. If you add User1 to group2 he is able to change File2. The command of your choice would be useradd. –  user1146332 Sep 9 '12 at 21:49
    
@GuntherStruyf I didn't change anything... From what I could tell, Ubuntu allows it by default... –  Aram Papazian Sep 9 '12 at 22:14
    
@user1146332 The whole point is to not add user1 to group2. If that is the only way then I can do that, but theoretically I'd prefer a group nesting structure... –  Aram Papazian Sep 9 '12 at 22:17

1 Answer 1

up vote 7 down vote accepted

There is no such thing as a group being a member of a group. A group, by definition, has a set of user members. I've never heard of a feature that would let you specify “subgroups” where members of subgroups are automatically granted membership into the supergroup on login. If /etc/group lists group1 as a member of group2, it designates the user called group1 (if such a user exists, which is possible: user names and group names live in different name spaces).

If you want user1 to have access to file2, you have several solutions:

  • Make file2 world-accessible (you probably don't want this)
  • Make user1 the owner of file2: chown user1 file2
  • Add user1 to group2: adduser user1 group2
  • Add an ACL to file2 that grants access to either user1 or group`:

    setfacl -m user:user1:rw file2
    setfacl -m group:group1:rw file2
    

    See Make all new files in a directory accessible to a group on enabling ACLs.

share|improve this answer
    
Yep, unix/linux doesn't support nested groups. It would be usful if it did, but it just doesn't. Windows does, and Active Directory does. LDAP does too, so it should be possible if the account and group data is in LDAP rather than in /etc/passwd and /etc/group files...but that's overkill when there are simple solutions like ACLs (or just add the user to both groups) –  cas Sep 10 '12 at 2:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.