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.
Create user group
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 |
DeleteUser group
groupdel frontend
Delete frontend user group
Modify user group information
groupmod -n backend frontend
Change the user group name from frontend to backend.
Set group password
gpasswd backend
Use gpasswd to set a group password for the backend user group.
User Group Member Management
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 |
View the groups to which the user belongs
groups zhangsan
Use the above command to view Which user groups does zhangsan belong to?
Users can join user groups independently
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.
Other configuration
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

