Add a user to group is a very easy and simple in Linux. You have two group for adding user that is primary group and secondary group in Linux system. you can add user either using useradd commands or usermod commands. If you use useradd command then you need to create a new user and add information of that user. If you use usermod commands than you just need to modify the existing user account to add user to the group.

If you want to add user to secondary group then use the following commands

Adding New Group:

If you want to add user to group then first you need to add group by simply using given commands.


groupadd <name of group>

Adding the existing user to Group:

If you want to add existing user to group then use the given command


usermod –a –G <group name> <username>

Changing User’ Group:

If you want to change the primary group to another than use given command.


usermod – g <group name> <user name>

Show Group Assignment of User:

If you want to see the group assignment of user then uses the given commands.


id <user name>


groups <user name>

View Group List:

For group list use the following commands



Using one command To Add User and Assign To Group:

If you need to add a new user that has accessed resources or directory than use the given commands.


useradd – g <group name> username

If you set the password for the user


passwd <user name>

Adding User to Multiple Group:

For adding the user to multiple group via using the given commands


usermod –a –G <group name 1>,<group name 2>,<group name3> <username>
First release
Last update
0.00 star(s) 0 ratings