How to add user in a group of Linux

To understand the method by which we can add the users in the group Linux, first we have to understand the groups in Linux. In Linux, we have the option to create a group of different users and assign them the same permissions and privileges to perform different tasks, for example, if we want to assign the permissions of writing to group A, we will add all the users who are supposed to write in group A and access them the writing or editing permissions.

In this write-up, we will explore the methods by which we can add the users to any group in any distribution of Linux.

How to add users in the Linux

To understand the method of adding a user, we will first find out the general syntax of adding a user in a Linux:

$ sudo adduser [name of the user]

The general syntax is simple, as we have to simply use the adduser command and type the name of the user, for example, we will add user “itslinuxfoss” using the command:

$ sudo adduser itslinuxfoss
how to handle linux files and direc...

The new user “itslinuxfoss” has been added in the Linux, we can see from the above output, that it asked to set the password for the new user, then asked some personal information of the user and in the end, confirm the authenticity of the above-provided information.

How to add users in the groups of Linux

First, we will make a group by the name of “MyEmployees” and use the groupadd command to make this group in Linux:

$ sudo groupadd MyEmployees

When the group is created, now will add a user “itslinux” in the group MyEmployees by using the command:

$ sudo usermod -a -G MyEmployees itslinux

In the above command, we have used two options, “a” which is used to add the user in the group and “G” options represents the group in which the new user has to be added. Now, we can find out whether the user “itslinux” has been added to the group “MyEmployees” or not by using the command:

$ grep itslinux /etc/group

The user has successfully added to the group MyEmployees.

Conclusion

The groups provide us ease to assign the different permissions of performing specific tasks to a number of users instead of assigning the users permissions individually. In this article, the method of adding the new user in the groups of Linux has been discovered.