groups
sudo groupadd
usermod -a -G
While a user account can be part of multiple groups, one of the groups is always the “primary group” and the others are “secondary groups”. The user’s login process and files and folders the user creates will be assigned to the primary group.
To change the primary group a user is assigned to, run the usermod command, replacingexamplegroup with the name of the group you want to be the primary and exampleusernamewith the name of the user account.
usermod -g
Note the -g here. When you use a lowercase g, you assign a primary group. When you use an uppercase -G , as above, you assign a new secondary group.
To view the groups the current user account is assigned to, run the groups command. You’ll see a list of groups.
groups
To view the numerical IDs associated with each group, run the id command instead:
id
useradd -G examplegroup exampleusername
(You’ll want to assign a password for that user afterwards, of course:)
passwd jsmith
usermod -a -G group1,group2,group3 exampleusername
getent group