Home>Article>Operation and Maintenance> How to check which users are in a user group in Linux

How to check which users are in a user group in Linux

青灯夜游
青灯夜游 Original
2022-06-17 17:24:07 25105browse

There are two ways to view all users under a user group in Linux: 1. Use the cat and grep commands to view the contents of the user group configuration file "/etc/group" and filter and output the information of the specified user group. , the syntax "cat /etc/group|grep group name" can output the user list in the specified user group. 2. Use the "sudo yum members" command to install the members tool package, and execute the "members group name" command to list all users under the specified user group.

How to check which users are in a user group in Linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Two ways to view all users under a user group in Linux

Method 1: Use cat and grep commands to view and filter "/etc/ group" file information

/ect/groupThe file is the user group configuration file, that is, all the information of the user group is stored in this file.

Each line in this file represents a user group. In each user group, ":" is still used as the separator between fields, which is divided into 4 fields. The corresponding meaning of each field is:

组名:密码:GID:该用户组中的用户列表

Just use the cat and grep commands to view "/etc /group" and filter and output the information of the specified user group

cat /etc/group|grep 组名

How to check which users are in a user group in Linux

Method 2: Use the members command to list all members of the specified user group Members

1. First install the members package

sudo yum members

2. List all members under a certain group


Example View the members under the ftponly group

members ftponly

How to check which users are in a user group in Linux

In this example, the members command displays a space-separated list of group member names on the screen.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check which users are in a user group in Linux. 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
Previous article:What does linux more mean? Next article:What does linux more mean?