Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I don't understand why newgrp prompts me for password when I want to change my group. I don't even know what password it is asking for but certainly not mine (user clime).

$ id
uid=500(clime) gid=501(www) groups=501(www),500(clime) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ newgrp clime
Password: <--- huh?!

My system is centos 6.3.

share|improve this question

marked as duplicate by Gilles, Renan, rahmu, jasonwryan, uther Feb 28 '13 at 13:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
what do you mean by "change my group"? Are you trying to log in to a group or are you trying to add your account to another group? –  h3rrmiller Feb 27 '13 at 17:30
    
i am trying to log into group clime there –  clime Feb 27 '13 at 18:27
add comment

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.

share|improve this answer
    
but i am a member of the group, see groups in my id output. –  clime Feb 27 '13 at 18:26
    
It is still used for those systems that have limited numbers of groups too! –  mdpc Feb 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. –  clime Feb 27 '13 at 19:11
    
newgrp isn't entirely obsolete. It allows you to switch your primary group still. –  derobert Feb 27 '13 at 22:02
add comment

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.

share|improve this answer
    
There is x instead of * but I guess it can have the same meaning. –  clime Feb 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. –  mdpc Feb 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. –  clime Feb 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. –  Nils Feb 27 '13 at 20:34
add comment

newgrp (1) alters two files, /etc/passwd and /etc/group. Both need root privileges to modify.

share|improve this answer
    
why doesn't it then require su(do) instead of implicitly authenticating you as root? –  amphibient Feb 27 '13 at 18:11
1  
No, newgrp does not alter any files. –  psusi Feb 27 '13 at 18:13
    
newgrp alters NO files..... –  mdpc Feb 27 '13 at 18:27
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.