Setting a user's supplementary groups on LinuxPosted in Linux/Unix/BSD -
A user on Linux belongs to a primary group, which is specified in the /etc/passwd file, and can be assigned to multiple supplementary groups, which are specific in the /etc/group file. The usermod command can be used after creating to user to assign them to additional groups(s).
Replace existing supplementary groups
Running usermod with the -G flag will replace all existing supplementary groups for the user with the ones specified. To assign "chris" to the "adm" group only, do this:
usermod -G adm chris
To assign "chris" to "adm" and "sudo", do this where multiple groups are separated with commas:
usermod -G adm,sudo chris
Adding a supplementary group to existing ones
If you want to add a supplementary group and not interfere with the other ones already set, add the -a flag (append) as part of the command.
To add "chris" to the "adm" group, leaving the other group assignments as-is, do this:
usermod -a -G adm chris
Setting the groups when adding a user
It's the same flag to set the supplementary groups when adding a user, -G:
useradd -G adm,sudo chris
The flags & commands should be the same on all Debian based distros (and others too); when writing this post I was using Debian 8.1.