The members
command is used to display a list of the members of a group in a Linux or Unix-like system. The members
command takes the name of a group as its argument and outputs the names of the users that belong to the group.
Here are some common examples of using the members
command:
- To display the members of a group:
members groupname
- To display the members of all groups:
for i in $(cat /etc/group | cut -d: -f1); do echo $i:; members $i; done
Note: The exact behavior of the members
command may vary depending on the system. Some systems may not have the members
command installed, in which case you can use the getent
command to display group information:
getent group groupname