LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Locate Users In A Specific Group (https://www.linuxquestions.org/questions/linux-general-1/locate-users-in-a-specific-group-919659/)

carlosinfl 12-20-2011 07:49 AM

Locate Users In A Specific Group
 
I've got a Linux server with ~200 user accounts on it. At one point accounts were genricly being created and their primary group (GID) was "users". Since I've taken over, I've created appropriate groups for users but my question is, how can I create a file w/ all the users on the system in /etc/passwd who have a primary GID of "users"?

droyden 12-20-2011 08:13 AM

grep users /etc/group

carlosinfl 12-20-2011 08:44 AM

Woops. There is nothing listed as "users" so I had to grep for the GUI "100" and that worked. Just had to trim out the one UID that was "100".

guna_pmk 12-20-2011 11:38 AM

Try this

Code:

getent passwd | grep $(grep user /etc/group | cut -d: -f3) | cut -d: -f1
Cheers


All times are GMT -5. The time now is 11:12 AM.