LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-29-2016, 02:25 AM   #1
scriptkiddy
LQ Newbie
 
Registered: Feb 2016
Posts: 18

Rep: Reputation: Disabled
Question groupmems vs /etc/passwd primary group


I added a few users to the users group "test1" "test2" and "test3" and set their primary group to users using following:

Code:
# usermod -g users test1
# usermod -g users test2
# usermod -g users test3
I then decided to create a new group and just add one user to it:
Code:
# groupadd gamers
# usermod -a -G gamers test1
Using groupmems, I checked to see who had gamers as their primary group:
Code:
# groupmems -l -g gamers
test1
I'm confused here because groupmems is supposed to show primary group memberships, so why is test1 showing, it should return nothing (I'm also confused on the syntax as groupmems --help indicates that the usage should be groupmems -g groupname -l...

Here is the result of users group:
Code:
# groupmems -l -g users
 test1  test2  test3
So test1 has two primary groups?

So I checked /etc/passwd
Code:
# more /etc/passwd | grep test1
test1:x:1001:100::/home/test1:/bin/bash
And it shows that the gid is 100 (users) which is in fact the primary group...

So which is right, groupmems or /etc/passwd, or does /etc/passwd simply showing the "first assigned" primary group vice the primary group? In any case how can a user have more than one primary group?

Please help me understand.

SK

Last edited by scriptkiddy; 02-29-2016 at 02:27 AM.
 
Old 02-29-2016, 02:33 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
user's cannot have more than one primary group. see /etc/group to check membership.
 
1 members found this post helpful.
Old 02-29-2016, 08:36 AM   #3
taea00
LQ Newbie
 
Registered: Feb 2016
Posts: 12

Rep: Reputation: Disabled
As pan64 said, users cannot have more than one primary group. You can run the "groups" command on a user to see what their groups are. Primary is listed first, secondary groups are after that.

I think you might be getting confused with the groupmems command though. Check the man page for groupmems with "man groupmems" and it will show you that -g is they group you're checking and -l is listing the users in that group. It isn't specifying primary or secondary groups.

I've never heard of groupmems before so I thank you for that interesting new command.
 
1 members found this post helpful.
Old 03-01-2016, 12:14 AM   #4
scriptkiddy
LQ Newbie
 
Registered: Feb 2016
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thanks for the replies. I agree a user cannot have more than one primary group which is why I was confused when I saw groupmems' output.
I think I'll just stick to groups (also new command for me). It seems to list the primary, then the supplementary groups, so that was easy, and the command is simpler than groupmems.

Many thanks for the insights and thoughts.

SK
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Primary Group greenleith Linux - Newbie 1 09-23-2011 03:58 AM
Secondary group users need to change the file permissions of primary group files? sunnybmv Linux - Newbie 3 12-10-2009 04:57 PM
what is primary group ram_rajavarapu Linux - Enterprise 2 01-23-2009 08:32 AM
The Primary Group ? outshined Linux - Newbie 1 07-14-2006 01:54 PM
What is a Primary Group? ejtbrown Linux - General 2 03-21-2001 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration