[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: newgrp oddities



Stephen Touset wrote:
> I su'd into root a moment ago to add my username to another group. 
> However, I'd really enjoy being able to have my group information 
> updated to include that gid without logging out and back in.

In a nutshell, you can't.  If you only need this in a window or two
you can 'exec login' in a window and log in again as yourself in that
window.  This will get you the new group permissions in that window.
Usually it would be 'exec login loginname' for best effect.

> I tried newgrp, but it asks me for a password (even though I'm
> listed in the /etc/group file under that group). I've also tried to
> newgrp to a group I'm already recognized as a member of, but it
> still asks for a password.  Reading through the man, it says it
> should only ask a password if a) the user has no password but the
> group does, or b) the user is not a member of the group.  If I'm
> listed under the group in /etc/group, and have a password, why is it
> prompting me for one (and since none of my groups have passwords
> listed, I can't enter the "correct" one)?

You would need to be a member of the group already.  The 'newgrp'
command only changes your primary group.  It will bring any of your
suplemental groups to the forefront and make it your primary group.

See the output of the 'id' command.  It will list both your primary
group and your suplemental groups.  If you are already a member of a
group you can make it your primary group so that any files you create
will be owned by that group.  But if you are not already in the group
then it goes through the password asking process.

The usefulness of newgrp is limited.  Usually it is exec'd to replace
the current shell instead of stacking a new one on top.  Generally
today the use of the user-private-group methodology has almost
completely replaced the need to ever run newgrp.

Bob

Attachment: pgpZwB8FVka93.pgp
Description: PGP signature


Reply to: