Groups can essentially have the following two types:
- Primary Group
- Secondary Group
The point to be noted here is that a user can be a part of one and only one Primary group, whereas he can be a part of more than one Secondary group. Therefore, in this article, we are going to explain to you the methods with which you can add a user to a group or groups in Debian 10.
Methods of Adding a User to a Group in Debian 10:
To add a user to a group or groups in Debian 10, you can make use of any of the two methods discussed below:
Method # 1:
In this method, we are going to explain to you how you can add a user to a single group at a time. For doing that, you will need to perform the following steps:
1. Click on the Activities tab located on your desktop as highlighted in the image shown below:
2. As soon as you will do this, a search bar will appear on your screen. Type terminal in that search bar and click on the search result to launch the terminal in Debian 10 as highlighted in the following image:
3. Doing this will launch the terminal window, which is shown in the image below:
4. Now type the following command in your terminal and then press the Enter key:
Here, replace GroupName with the name of the group to which you want to add the user and UserName with the name of the user whom you want to add in the group. In this example, I wanted to add the user KBuzdar to the sudo group. Therefore, I have replaced GroupName with sudo and UserName with KBuzdar. As soon as this command executes successfully, the specified user will be added to the specified group. This command is also shown in the following image
Method # 2:
In this method, we are going to explain to you how you can add a user to multiple groups at the same time. For doing that, you will need to perform the following steps:
Launch the terminal in the same way as described in the method above. Now type the following command in your terminal and then press the Enter key:
Here, you can add as many groups as you want, separated by a comma, as shown above. Replace GroupName[s] by the names of all the groups to which you want to add your user and UserName with the name of the user that you want to be added to the specified groups. In this example, I wanted to add the user KBuzdar to the sudo and docker groups. Therefore, I have replaced GroupName[s] with sudo and docker and UserName with KBuzdar. As soon as this command executes successfully, the specified user will be added to the specified groups. This command is also shown in the image below:
Conclusion:
By following the two methods described in this article, you can conveniently add a user to a group or even multiple groups at a time. In this way, you will not have to grant each user with the same privileges separately; rather, they will automatically be granted to them once they become a part of a certain group. This will not only save your precious time but will also increase your productivity.