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

青灯夜游
Release: 2022-06-17 17:24:07
Original
25174 people have browsed it

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/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:该用户组中的用户列表
Copy after login

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

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

2. List all members under a certain group


Example View the members under the ftponly group

members ftponly
Copy after login

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template