If I add myself to a group, it applies only to newly launched processes. Actually it's more restricted than that; it seems to apply only to new logins. I'm not sure what the exact mechanism is, but that's not my question (though I'm curious about that too).
My question is this: Is it possible to update my group membership in the current shell process?
I suspect the answer is no.
An example (this is not a direct copy-and-paste):
$ groups ; groups kst
kst oldgroup1 oldgroup2
kst : kst oldgroup1 oldgroup2
$ sudo adduser kst newgroup
[sudo] password for kst:
Adding user `kst' to group `newgroup' ...
Adding user kst to group newgroup
Done.
$ groups ; groups kst
kst oldgroup1 oldgroup2
kst : kst oldgroup1 oldgroup2 newgroup
$
After the adduser
, my account is a member of newgroup
, but that membership is not reflected in the current shell process.
The obvious solution is to log out and log in again, but that's inconvenient.