Ubuntu - How to add user to group

All user account related information are stored in the following files:
 
/etc/passwd – Contains one line for each user account.
/etc/shadow – Contains the password information in encrypted formatfor the system’s accounts and optional account aging information.
/etc/group – Defines the groups on the system.
/etc/default/useradd – This file contains a value for the default group, if none is specified by the useradd command.
/etc/login.defs – This file defines the site-specific configuration for the shadow password suite stored in /etc/shadow file.

 
Create group:
groupadd developers

useradd Example – Add a new user to secondary group
useradd -G {group-name} username

usermod example – Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with the usermod command using the -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:
usermod -a -G ftp tony

In this example, change tony user’s primary group to www, enter:
usermod -g www tony

gpasswd example – Add a existing user to existing group
gpasswd -a groupName UserName