RHEL 中 "members" 的等效命令

Equivalent Command for "members" in RHEL

我有要求定期查看群成员"wheel"。

我看到 'members wheel' 应该显示该组的成员。但是,当我尝试时,它说找不到命令。我在手册页中也看不到任何条目。

我正在使用 RHEL - Linux 版本 3.10 (Red Hat 4.8.5)

我知道我们可以结合使用 awk 和 cat 从“/etc/group”文件中获取这些详细信息

但是有直接的或更好的方法吗?

这是一个answered question from Linux admin

简而言之,答案是:

I prefer to use the getent command ...

Since getent uses the same name service as the system, getent will show all information, including that gained from network information sources such as LDAP.

So for a group, you should use the following ...

getent group name_of_group

where name_of_group is replaced with the group you want to look up. Note that this only returns supplementary group memberships, it doesn't include the users who have this group as their primary group.

There are a whole lot of other lookups that you can do ... passwd being another useful one, which you'll need to list primary groups.