Home >Operation and Maintenance >Windows Operation and Maintenance >CentOS user group management
In the Linux system, there are two system files closely related to user groups, they are: /etc/group, /etc/gshadow .
/etc/group: Stores user group information.
Each record in the file follows the same format: Group name: Group password: GID: Group member list . For example, the GID of the mail user group is 12, and the group members include mail and postfix.
/etc/gshadow: Stores the password information of the user group.
Each line follows the same format: Group name: Group password: User group administrator account: Group member list. For example, for the User Management members of the mail user group, the group password is hidden, there is no group administrator, and there are two members: mail/postfix.
groupadd -g 888 frontend
Create the frontend user group and specify the user group ID. Commonly used groupadd parameters refer to the following table:
Parameter | Description |
---|---|
-f | Success if group already existsExit |
-g | Use GID for new group |
-h | Display this help message and exit |
-K | Do not use the default value in /etc/login.defs |
-o | Allows the creation of groups with duplicate GIDs |
-p | is a new group Use this encrypted password |
-r | to create a system account |
-R | chroot Directory to go to |
groupdel frontend
Delete frontend user group
groupmod -n backend frontend
Change the user group name from frontend to backend.
gpasswd backend
Use gpasswd to set a group password for the backend user group.
gpasswd -a zhangsan backend
The above command adds zhangsan to the backend user group. For more optional parameters of the gpasswd command, please refer to the following table:
Parameter | Description |
---|---|
-a | Add user to user group |
-d | Remove user from existing user group |
-A | Set user group administrator |
-r | Delete user group password |
-R | Prohibit users from joining this group |
groups zhangsan
Use the above command to view Which user groups does zhangsan belong to?
gpasswd allows administrators to add members to user groups. If users know the group password, they can also join the user group themselves.
newgrp backend
The above command adds the current user to the backend user group and enters the group password as prompted.
File | Description |
---|---|
/ etc/login.defs | Set the default warning time, maximum validity time and other information of the useradd command. |
/etc/default/useradd | Set the default home directory of the useradd command, the shell used, etc. |
/etc/motd | Stores the prompt information after successful login. |
/etc/issue | Stores the login prompt information. As long as you try to log in, it will prompt the information in this file, which usually stores some welcome information. |
The above is the detailed content of CentOS user group management. For more information, please follow other related articles on the PHP Chinese website!