linux: refreshing groups without having to re-login

10

2

Possible Duplicate:
Is there a way in Linux to update the user/group properties without having to login again?

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

moo

Posted 2010-04-24T23:31:35.883

Reputation: 897

Question was closed 2013-01-14T16:56:52.927

1fyi. 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 – 2010-04-25T01:49:49.750

Answers

18

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

xenoterracide

Posted 2010-04-24T23:31:35.883

Reputation: 628

2this 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 – 2010-04-25T13:31:05.877

3Prefix with exec (exec newgrp groupname) if you don't want to have an old shell process laying around. – user1686 – 2010-04-25T15:24:44.820

1@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 – 2010-04-26T01:16:39.357

7

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

Ignacio Vazquez-Abrams

Posted 2010-04-24T23:31:35.883

Reputation: 100 516

1this 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 – 2010-04-25T01:14:41.210