In ubuntu 18.04 with default desktop, behaviour of logout/login has changed:
Previously on an Ubuntu system, when I find that I need to add my user id to some group, it was sufficient to
sudo adduser ludwig docker # adds me to group docker
and then I had to logout and login again to make the group change effective.
I notice that with Ubuntu 18.04, after adding the group and logging out and back in, the list of effective groups is still unchanged.
As a workaround I rebooted the system, which is inconvenient (requires making the right selection in grub and re-entering the disk encryption password).
- Why is the behaviour now like this?
- Can I do something else short of rebooting?
(I know I can ssh into localhost and get the correct groups in the ssh session only. This is also too inconvenient.)
The command
loginctl terminate-user $USER
worked for me. You probably shouldn't run this when logged in though as it will kill all your processes.When "logging out" of the default desktop in ubuntu 18.04, some of the user's processes are not terminated immediately, but linger around. These are (observed by another user):
When logging back in before these processes exit voluntarily, then no new login session is created, but the old one is reused. This is the reason why the new group membership is not visible, it is still the same old login session.
A workaround to avoid rebooting is to wait ~20 seconds after logging out and only then logging back in. The processes exit somewhere between 10 and 20 seconds after logging out.
Edit: As reported in the comments below, sometimes the lingering processes will not quit even with waiting, and after logging back in, the group memberships have not been updated. I found that in this case it helps to
Replace
ludwig
with your user name. This kills all processes that belong to you. Use only when you're sure you have all your data in all your open programs saved.A workaround in the current shell is to run "su " to have the new group without having to reboot.
As I said, this trick has to be applied to each shell. That's not global.