User group management
1. User group file/etc/group
[[email protected] ~]# tail -N3/ETC/Group // View data of the last three lines under the/group
testgroup:x:1001:
user2:x:1002:
grp1:x:1003:
Note: The result of the output is the same as the first three lines of/etc/passwd. Please refer to the first three lines of the previous blog post/ETC/PASSWD.
2. User backup instructions
- Enter the command, don’t return to the car, use TAB to complete, the following effect will be displayed
[root@localhost ~]# ls /etc/shadow // Password configuration file
shadow shadow-
[root@localhost ~]# ls /etc/passwd // User configuration file
passwd passwd-
[root@localhost ~]# ls /etc/group // User group file
group group-
[root@localhost ~]# ls /etc/gshadow // User group password configuration file
gshadow gshadow-
Note: The group-, passwd-, represents the backup file of the file, if the user or the file is deleted, recover with it.
3. Added and delete user group
-
command grammar
groupadd [-g GID] groupname -
command description
new user group -
command option
-G custom GID. If you do not add -G options, you can create a group according to the default GID of the system. Like UID, GID starts from 1 1.
command example
- Create user group
[root@localhost ~]# groupadd grpp1 // Create user group
[root@localhost ~]# tail -n1 /etc/group // View the last line of user group files (group). (Each user group is created by default, and a line of data will be added in the last line of the group file).
grpp1:x:1004: // Refer to the first three lines of/ETC/PASSWD
- While creating a user group, custom GID (GID must be above 1000, and the system user group is within 1000)
[root@localhost ~]# groupadd -g 6666 grpp2
[root@localhost ~]# tail -n1 /etc/group
grpp2:x:6666:
- Delete the user group (Groupdel)
[[email protected] ~]# groupdel grpp2
[[email protected] ~]# tail -n3 /etc/group
user2:x:1002:
grp1:x:1003:
grpp1:x:1004:
can be seen from the code that GRPP2 has been deleted.
Note: When we delete the user group, the premise is that there are no users in the user group.