How to tell if a user is a group member in a script?

Kevin P. Fleming kpfleming at linuxfromscratch.org
Wed Oct 20 15:16:54 PDT 2004


Matthew Burgess wrote:

> I can cheat :)  You said you didn't want to parse /etc/group.  How about 
> parsing /etc/passwd instead then to get a list of users :)  You can then 
> loop over that list and run 'groups' on them :)

Well, I already know the username, so using 'groups' is just fine, I can 
then use grep or something to see if the desired group name is in the list.

Thanks!



More information about the lfs-chat mailing list