Re: Shell script to list group members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Bob Beers wrote:
> grep <group_name>: /etc/group | cut -d: -f4
>
> will give a comma separated list, provided <group_name> is a valid group name.
>
>   
There is one problem with this approach, which is the assumption that
all users' primary group is the same as their login id - which I agree
is typically the RHEL way, but it doesn't have to be the case.  If
however you have users with their primary group set to something other
than the login id - e.g. "admin" or "marketing" - then you need to look
in the /etc/passwd file as well because these users don't appear in the
comma separated list outlined above.  To check the /etc/passwd file, you
have to determine the group id value, and then scan the /etc/passwd file
looking for that value in column 4.  This will give you a list of users
whose primary group is the group value you're interested in.

Cheers,

Ian

<<attachment: smime.p7s>>

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux