Add User to Linux Group
It is very common to perform user inclusion to an existing group. This section guides you on how to add user into Linux Group.
Prerequisite
Prerequisite
Before starting to add user into a group, you must make sure that both group and users are available.
Add User To Group
Add User To Group
To add user into group, there are a number of ways: choose 1 of the following subsections.
Manual Add
Manual Add
You can manually edit the /etc/group
file by searching the group name and add the user from the list. Example, to add "user2" into "mygroup":
mygroup:x:1274:user1,user3
to
mygroup:x:1274:user1,user2,user3
Using usermod
Using usermod
Yo can also use usermod command to add all secondary groups at once using append argument:
$ usermod -a -G <all wanted groups> <user>
Following the example above, it is:
$ usermod -a -G mygroup,groupT,groupV user2
That's all for adding user into group.