Linux: Refresh user's group membership without logout/login
Posted: Wed Mar 16, 2011 3:44 pm
[PROBLEM]
If a system user is assigned newly to a group, this membership usually only takes effect after logging out and back in.
In some cases though, it's not that easy (or not possible) to simply logout and back in, so it would be great to apply that group membership immediately.
[SOLUTION]
You can join a group using the "newgrp" command (found that info in a debianhelp forum entry).
This only works on the fly, if the group has a group-password set, so the user can "join" it.
Even if you don't want to have group passwords (e.g. security reasons), I've decided in my case to temporarily add a password.
So here we go:
1) Assign a group-password to the group you want to join:
2) Join that group, using "newgrp":
3) (optional) Verify that the group membership is now active:
That's it.
If a system user is assigned newly to a group, this membership usually only takes effect after logging out and back in.
In some cases though, it's not that easy (or not possible) to simply logout and back in, so it would be great to apply that group membership immediately.
[SOLUTION]
You can join a group using the "newgrp" command (found that info in a debianhelp forum entry).
This only works on the fly, if the group has a group-password set, so the user can "join" it.
Even if you don't want to have group passwords (e.g. security reasons), I've decided in my case to temporarily add a password.
So here we go:
1) Assign a group-password to the group you want to join:
Code: Select all
gpasswd <groupname>
Code: Select all
newgrp <groupname>
Code: Select all
groups