When I add myself "vboxusers" group I an no longer in the "admins" group
Solution 1:
Your second command is right.
By default, usermod -G
replaces all supplementary groups the user is in (the primary group is generally named the same as your username, and specified separately; don't mess with that though). By also using -a
it appends the groups you give.
So this should work (and does, for me, just tried it):
usermod -aG vboxusers myusername
If running that command takes you out of any other group then you've found a bug. Note you have to relogin to see the effects.
Solution 2:
Alternatively:
gpasswd --add myusername vboxusers
Solution 3:
According to the usermod man page
the correct command to add a user to a group is
sudo usermod -G group -a username
or in your case since you want to add your self to the vboxusers
group that will be
sudo usermod -G vboxusers -a $USER
Solution 4:
Never use the top method to add a user to vboxusers
by using the usermod -G vboxusers myusername
command. This will make you lose your sudo privileges!
If you have lost your sudo privileges, you can use the method described here to recover them. It boils down to executing the following command:
usermod -G adm,cdrom,sudo,dip,plugdev,lpadmin,guoshicheng,vboxusers myusername