I've got the basics of primary and secondary groups down, but still have some questions I can't seem to find solid answers to:
- Can many users belong to the same primary group?
- Can one user's primary group be a secondary group of another user?
I've got the basics of primary and secondary groups down, but still have some questions I can't seem to find solid answers to:
Yes, they can.
$ id foo
uid=1002(foo) gid=1002(foo) groups=1002(foo)
$ id bar
uid=1003(bar) gid=1003(bar) groups=1003(bar)
Changing the primary group of user foo
to bar
which is the primary group for user bar
:
$ sudo usermod -g bar foo
Now:
$ id foo
uid=1002(foo) gid=1003(bar) groups=1003(bar)
$ id bar
uid=1003(bar) gid=1003(bar) groups=1003(bar)
Yes, it can be.
$ id foo
uid=1002(foo) gid=1002(foo) groups=1002(foo)
$ id bar
uid=1003(bar) gid=1003(bar) groups=1003(bar)
Adding user bar
to group foo
which is the primary group of user foo
:
$ sudo usermod -a -G foo bar
Now:
$ id foo
uid=1002(foo) gid=1002(foo) groups=1002(foo)
$ id bar
uid=1003(bar) gid=1003(bar) groups=1003(bar),1002(foo)
From the perspective of the user, he has a primary group and 0 or more secondary groups.
From the perspective of the group, it has 0 or more members.
A group that is the primary group for one or more users can be both a secondary or primary group for other users.