Group Management
User/Group Relationship
Primary Group
When a user is created, a group with the same name is also created, which is the primary group.
The fourth field indicates the primary group ID 1001, which can also be viewed using the groups command.
Secondary Groups
Users can also belong to multiple secondary groups, used for permission access control.
ID Command
The most practical command for viewing user group information.
gid
indicates the primary group, and groups
indicates the secondary groups.
/etc/group
The configuration file for groups, modified using commands, do not manually edit, otherwise, it will be messed up.
Group Information
Viewing the information of the sudo group
- Group Name: sudo
- Password: x
- Group ID: 27
- Member: kuga
Multiple group members are separated by commas: kuga,soda
.
Creating a New Group
Modifying Group Name
User Group Assignment
Preserving Secondary Groups
This method does not overwrite the list of secondary groups.
Overwriting Secondary Groups
Removing the -a
(append) option will overwrite the entire secondary group list.
Clearly, the soda group is gone.
Deleting Secondary Groups
Deleting the sudo secondary group of the soda user.
Alternatively, you can use the overwrite method, keeping only the soda group.