-   Linux - General (
-   -   Locate Members of a Group? (

carlosinfl 09-05-2008 12:29 PM

Locate Members of a Group?
I am trying to remove the "users" group and it tells me I can't remove someones primary group however when I check /etc/group, I show nobody's name next to the GID. Is there a command I can run that will tell me all the members of the specific GID or how can I check who is a member of this group?


sin0nyx 09-05-2008 01:58 PM

A users primary group is set in the /etc/passwd file. It is the fourth entry and listed numerically. To delete the group you will first need to delete the user or change their primary group.

# grep test /etc/passwd
# grep 65534 /etc/group

carlosinfl 09-05-2008 02:03 PM

Something is wrong here...


[root@lt2fs3 /]# grep users /etc/passwd
[root@lt2fs3 /]# cat /etc/passwd | grep users
[root@lt2fs3 /]# cat /etc/group | grep users
[root@lt2fs3 /]# groupdel users
groupdel: cannot remove user's primary group.

Poetics 09-05-2008 02:12 PM

If you take a look in the /etc/passwd file, you will see that none of the groups are listed by name, only by GID. Try grepping for '508' through your passwd file, as that seems to be the GID of your 'users' group.

carlosinfl 09-05-2008 02:16 PM

OK that makes sense. For some reason when I look for 508 in /etc/passwd, I find a boat load of accounts with gid of 508. Not sure why they don't show up on /etc/group under the users section. Is it safe to modify the /etc/passwd file by hand?

Poetics 09-05-2008 02:23 PM

If you are just looking to adjust their primary group (make sure to have them in at least one group), it shouldn't be an issue to edit them manually, though there's likely some command-line tool for doing just that if you don't want to get your hands dirty in /etc/passwd

Personally I've never had a problem with it.

carlosinfl 09-05-2008 02:26 PM

I just opened vim and ran:


The above replaced all 508 groups with 100 GID and then I saved it and removed the group. Thanks all!

All times are GMT -5. The time now is 01:21 PM.