After adding a group, logout+login is not enough in 18.04?

Solution 1:

The command loginctl terminate-user <user> worked for me. (Replace <user> with your user name) You probably shouldn't run this when logged in though as it will kill all your processes.

Solution 2:

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):

$ ps axu | grep ^ludwig
ludwig    26508  0.3  0.2  77052  8308 ?        Ss   23:32   0:00 /lib/systemd/systemd --user
ludwig    26509  0.0  0.0 261776  2968 ?        S    23:32   0:00 (sd-pam)
ludwig    26691  0.2  0.3 381288 12204 ?        S<l  23:32   0:00 /usr/bin/pulseaudio --start --log-target=syslog
ludwig    27352  0.0  0.0  49796  3756 ?        Ss   23:33   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only

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

ps axu | grep ^ludwig | awk '{print $2}' | xargs kill -9

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.

Solution 3:

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.