Table of Contents
Create user group
Modify user group information
Set group password
User Group Member Management
View the groups to which the user belongs
Users can join user groups independently
Other configuration

CentOS user group management

May 28, 2017 am 10:31 AM
user group

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.

CentOS user group management

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.

CentOS user group management

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
Copy after login

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
Copy after login

Delete frontend user group

Modify user group information

groupmod -n backend frontend
Copy after login

Change the user group name from frontend to backend.

Set group password

gpasswd backend
Copy after login

Use gpasswd to set a group password for the backend user group.

User Group Member Management

gpasswd -a zhangsan backend
Copy after login

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
Copy after login

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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)