3 Answers
3

newgrp is a vestigial command from the days when the kernel would only keep track of one group at a time, so if you were a member in more than one, you had to use this command to switch groups. If you are not listed as being a member of the group, the group may be assigned a password that you can enter to switch to it. That is what you are being prompted for.

but i am a member of the group, see groups in my id output.
–
climeFeb 27 '13 at 18:26

It is still used for those systems that have limited numbers of groups too!
–
mdpcFeb 27 '13 at 18:28

@psusi: but you are otherwise right that I don't need newgrp anymore (at least on my home computer). At work we have still some older systems that needs it. I didn't realize it has changed.
–
climeFeb 27 '13 at 19:11

BTW, you might not realize it but there is a passwd field in the /etc/group file. This field is either NULL (i.e. ::) or a STAR (i.e. *) is placed there. I suspect in your case the latter for this group, that a star (i.e. *) is placed in the passwd file. Thus with the group entry having what the system sees as a non-null password entry in the group file the newgrp command will respond as is appropriate.

There is x instead of * but I guess it can have the same meaning.
–
climeFeb 27 '13 at 19:21

Yes that is the case, basically if the field is non-NULL the newgrp program will request a password. I guess x is another good filler character.
–
mdpcFeb 27 '13 at 20:10

even after removing that x, newgrp still asks for password. I have set the password using gpasswd so at least I can switch now.
–
climeFeb 27 '13 at 20:26

On RedHat-based systems there is a /etc/gshadow. Like /etc/passwd the x just denotes that there is an existing entry in the shadow-file (which in turn contains the hashed password. gconv will create a missing gshadow-entry and create that x.
–
NilsFeb 27 '13 at 20:34