When adding a user to a group in Linux (red hat ) does matter if the text user name shows in /etc/group

Robert Silver
Robert Silver used Ask the Experts™
on
When adding a user to a group is it necessary to add the text user name to /etc/group ?
The reason I am asking is because I see the user I added with the group number
but there is no mention of that user in /etc/group. I would assume please correct me if I am not correct that if I add a user with  a group ID =617 and  so long as there exists a #617 group
that user is part of that group.
The part that has me confused is - Is it true you must first esentailly become the group to use the permisions of that group

e.g in /etc/group
Skiers:x:617:joe,howard,mike
I add a new user named sam
in the adding I specify 617 as the group but it does not show in /etc/group

Will that work. Can user sam be in the Skiers group and if so can sam not show up in
the /etc/group file but because 617 is the created user default group still be in that group?

I believe I am correct here I just want confirmation that the only need you have of the
names within the group entries in /etc/group is if multiple groups are specified for a user
then and only then those entries become important
Could some one please confirm this?
Also when use newgrp   myothergroup
do you lose your security state from say Skiers or are those security states appended
e.g if I am a member of both Skiers and    Pilots  and I newgrp Pilots  do I still have Skiers rights?
e.g could modify  skislopes.txt with owner root and group Skiers
asuming group write permisions exist for group Skiers??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
Commented:
the group specified while creating the user is mentioned in the /etc/passwd file, any other groups the user is added to, then the user name is added against that group name in /etc/group
Top Expert 2007

Commented:
A user has a primary group and optionally secondary groups.

The primary group ID (GID) is specified in /etc/passwd and the username doesn't need to be explicity listed in /etc/group as it is implied.

A user can belong to any number of other groups (secondary groups) and this is where you need to add their username to the appropriate group name in /etc/group

When you run 'newgrp' you are effectively changing your primary group (real group ID) to the new group name.

If you have a file

skiers.txt with an owner of root a group of skiers and permissions of at least 660, then so long as you are a member of skiers group (no need for newgrp), then you can modify the file.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial