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.
#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/group
The 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 组名
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
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!