0

I'm on a fresh installation of Ubuntu 18.04. During installation, I chose the minimal installation instead of the standard one.

I just added myself to the docker group using the following command

sudo usermod -a -G docker danny

I have logged out from my GNOME session (I tried both, from the top bar's menu, and from searching for "logout"). But my user did not get assigned to the docker group. However, if I su into my user, the group is there so the previous command did not fail.

$ groups
danny adm cdrom sudo dip plugdev lpadmin sambashare
$ groups danny
danny adm cdrom sudo dip plugdev lpadmin sambashare docker
$ su - danny
$ groups
danny adm cdrom sudo dip plugdev lpadmin sambashare docker

I had to do a full OS reboot for the change to take effect.

I have already rebooted, but this the ouput of id;

$ id
uid=1000(danny) gid=1000(danny) groups=1000(danny),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare),999(docker)

But I'm wondering why logging out isn't enough?

P.S. I am able to reproduce this behavior by adding myself to any random group, not just docker.

  • I even tried su - $USER too, same result. There are no other users on this installation (besides the system ones). Also, I am able to reproduce it with any group, not just docker. – Dan May 10 '18 at 12:03
0

You don't need to reboot to assign the additional group to your user. In the running shell the group assignment doesn't change, but it does in a new shell:

jean@myLinux:~$ sudo groupadd tester
[sudo] password for jean: 
jean@myLinux:~$ sudo usermod -a -G tester jean
jean@myLinux:~$ id
uid=1000(jean) gid=1000(jean) groups=1000(jean),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin),128(sambashare),129(vboxusers)
jean@myLinux:~$ su - jean
Password: 
jean@myLinux:~$ id
uid=1000(jean) gid=1000(jean) groups=1000(jean),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin),128(sambashare),129(vboxusers),1003(tester)
  • That part I understand, but what I don't understand is how come I wasn't assigned to the new group after I logged out and then logged back in. – Dan May 10 '18 at 15:00
0

You can also use the newgrp command to join a new group:

jean@myLinux:~$ id
uid=1000(jean) gid=1000(jean) groups=1000(jean),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin),128(sambashare),129(vboxusers)
jean@myLinux:~$ newgrp - newgroup
jean@myLinux:~$ id
uid=1000(jean) gid=1003(newgroup) groups=1003(newgroup),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin),128(sambashare),129(vboxusers),1000(jean)

I must confess that I'm as surprised as you that logout / login doesn't assign the new group, but su - does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.