Add user to group

For example, add user alikia to group git:

usermod -a -G alikia git

Change a User’s Primary Group

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.

For example, set the primary group of user user1 to group1 :

usermod -g group1 user1

View the Groups a User Account is Assigned To

To view the groups the current user account is assigned to, run the groups command. You’ll see a list of groups.

Add argument after groups to specify which user’s group you want to view, eg:

alikia@alikia2x:~$ groups
alikia sudo

Example 1: The user alikia is assigned to alikia and sudo groups.

alikia@alikia2x:~$ groups git
git : git alikia

Example 2: The user git is assigned to git and alikia groups.

Reference

[1] How-To Geek