How does one refresh the groups that a logged-in user is in without having to re-login?

link|improve this question

1  
fyi. the answer marked correct is wrong... and it's still technically a relogin. I added a correct answer... I find that the answer given to this question is usually wrong. it is a common fallacy. – xenoterracide Apr 25 '10 at 1:49
feedback

2 Answers

up vote 5 down vote accepted

possible in shell (I don't think it is for gui)

try newgrp groupname

I wrote more info on this on my blog a while back. according to that this will also change the default group of the shell. you can use sg to Switch your default Group

link|improve this answer
this is essentially no different that doing su - username as ignacio pointed out. a new shell process gets loaded and layered on top of the old one. however, you are still technically correct :) – moo Apr 25 '10 at 13:31
1  
Prefix with exec (exec newgrp groupname) if you don't want to have an old shell process laying around. – grawity Apr 25 '10 at 15:24
@orlandu63 except su changes your user and the - means change your whole env too. It also can mean you have to login. newgrp doesn't. @grawity I didn't know that. thanks for the tip. – xenoterracide Apr 26 '10 at 1:16
feedback

su - username will do it for the shell (and subproccesses) that su opens up, but for everything else you'll need to relog.

link|improve this answer
1  
this answer is incorrect especially since su is re-logging in. use newgrp in an open shell session to add groups to that session, that you've been added to. – xenoterracide Apr 25 '10 at 1:14
feedback

Your Answer

 
or
required, but never shown

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