What is the difference between primary group and secondary group in Ubuntu?
Ubuntu – the difference between primary group and secondary group in Ubuntu
groups
Related Question
- Ubuntu – the difference between the groups “adm” and “admin”
- Ubuntu – the group id of this group name
- Ubuntu – Relationship between file/folder’s owner and group
- Ubuntu – groupdel: cannot remove the primary group of user ‘administrator’
- Ubuntu – Permission difference between root root and www-data root
- Ubuntu – the purpose of the group named “users”
- Ubuntu – Difference between adduser and usermod -G -a
Best Answer
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
.