Search code examples
linuxrhel

Equivalent Command for "members" in RHEL


I have requirement to check members of the group "wheel" periodically.

I see that 'members wheel' is expected to display the members of that group. However when i tried, it says command not found. I see no entries in the man page as well.

I am using RHEL - Linux Version 3.10 (Red Hat 4.8.5)

I know we can use awk and cat in combination to get these details from "/etc/group" file

But is there a straight forward or a better approach?


Solution

  • This is an answered question from Linux admin.

    In short the answer is:

    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.