Home  >  Article  >  Operation and Maintenance  >  CentOS user group management

CentOS user group management

大家讲道理
大家讲道理Original
2017-05-28 10:31:152186browse

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

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!

Statement:
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