The primary group is the group applied to you when you log in using the usual methods (TTYs, GUI, SSH, etc.).
Since processes usually inherit the group of the parent, and your initial process or shell would have your primary group as the group, anything you do usually has the effect of the primary group on it (creating files, for example).
The secondary groups are the groups you can start processes as without using a group password, either via sg or to log in to via the newgrp command.
So if you have a primary group x and a secondary group y,
touch foo
will usually create a file with x as the group owner (unless the parent directory is SETGID to another group). However, you can do:
sg y 'touch bar'
# or
newgrp y
touch baz
Then bar and baz will be created with y as the group.
However, if you don't have a group in your secondary groups (say z), the sg and newgroup commands will ask for the group password if you use them with z.
If you are talking about file system groups, they are pretty well explained here cyberciti article. The primary group is used by default when creating a new file. You can test this
touch foo
ls -la foo
The file will be owned by you and be in your primary group. Users who are also in your primary group will have group level permissions on those files.
You can check your secondary groups with
groups $(whoami)
It also possible to share files with people who are not in your primary group by setting Set Group ID on a directory. This is explained here: shared folder with SetGID.
The primary group is the group applied to you when you log in using the usual methods (TTYs, GUI, SSH, etc.).
Since processes usually inherit the group of the parent, and your initial process or shell would have your primary group as the group, anything you do usually has the effect of the primary group on it (creating files, for example).
The secondary groups are the groups you can start processes as without using a group password, either via
sg
or to log in to via thenewgrp
command.So if you have a primary group
x
and a secondary groupy
,will usually create a file with
x
as the group owner (unless the parent directory is SETGID to another group). However, you can do:Then
bar
andbaz
will be created withy
as the group.However, if you don't have a group in your secondary groups (say
z
), thesg
andnewgroup
commands will ask for the group password if you use them withz
.If you are talking about file system groups, they are pretty well explained here cyberciti article. The primary group is used by default when creating a new file. You can test this
The file will be owned by you and be in your primary group. Users who are also in your primary group will have group level permissions on those files.
You can check your secondary groups with
It also possible to share files with people who are not in your primary group by setting Set Group ID on a directory. This is explained here: shared folder with SetGID.