I. Add, toggle, delete user Group commands Groupadd/newgrp/groupdel
1. Groupadd command
Used to create a new user group. The syntax format is:
Groupadd [-g-o] GID Group
The specific meanings of each option are as follows:
-G: Specifies the GID number of the new user group, which must be unique and cannot be duplicated with the GID number of other user groups.
-O: Typically used concurrently with the-G option, which means that the GID for the new user group is the same as the GID for the system already has a user group.
For example:
Create a Linuxfans user group and a Fanslinux user group, with GID 1020 and 1030 respectively
[Root@localhost ~]# groupadd-g 1020 Linuxfans
[Root@localhost ~]# groupadd-g 1030 Fanslinux
[Root@localhost ~]# More/etc/group|grep Linuxfans
LINUXFANS:X:1020:
[Root@localhost ~]# More/etc/group|grep Fanslinux
fanslinux:x:1030:
2. NEWGRP command
If a user belongs to more than one user group, the user can switch between user groups so that they have permissions from other groups of users, and NEWGRP is primarily used to switch between multiple user groups, in the form of:
Newgrp < user group >
Example: The following is an example that describes the use of NEWGRP:
First, 3 user groups group1, group2 and Group3 were established.
[Root@localhost ~]# Groupadd group1
[Root@localhost ~]# Groupadd group2
[Root@localhost ~]# Groupadd Group3
The following creates a user User1 and specifies that the primary user group for the User1 is group1, and that the additional user group is group2 and Group3
[Root@localhost ~]# useradd-g group1-g group2,group3 user1
[Root@localhost ~]# More/etc/group|grep user1
Group2:x:501:user1
Group3:x:502:user1
The following is a password set for the user User1
[Root@localhost ~]# passwd user1
Changing password for user user1.
New UNIX Password:
Retype new UNIX Password:
Passwd:all authentication tokens updated successfully.