[CentOS] Shell script to list group members
Ian Blackwell
ian at ikel.id.auTue Sep 23 23:37:15 UTC 2008
- Previous message: [CentOS] Shell script to list group members
- Next message: [CentOS] Shell script to list group members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3617 bytes Desc: S/MIME Cryptographic Signature URL: <http://lists.centos.org/pipermail/centos/attachments/20080924/e0f247d4/attachment-0001.bin>
- Previous message: [CentOS] Shell script to list group members
- Next message: [CentOS] Shell script to list group members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list