How to Add an Existing User to Multiple Groups in Linux/Ubuntu?
Linux/Ubuntu is a multi-user operating system, that enables multiple users having different privileges to operate independently on the same device. These privileges are assigned via Groups. A Group is a cluster of users with the same privileges. A group could be either primary or secondary. All the groups (other than primary) associated with the user are called secondary groups. The primary group is assigned at the time of user creation while the user is added to the secondary groups manually. A system administrator can assign a user to single or multiple groups via Terminal and GUI (Graphical User Interface).
This article will demonstrate the following methods to add an existing user to several groups in Linux/Ubuntu:
- How to Add an Existing User to Multiple/Different Groups via CLI in Linux/Ubuntu?
- Method 1: Add an Existing User to Multiple/Different Groups via the “usermod” Command
- Method 2: Add an Existing User to Multiple/Different Groups via /etc/group File
- Method 3: Add a New User to Multiple/Different Groups via the “useradd” Command
- Method 4: Add Multiple Existing Users in Multiple/Different Groups
- How to Add an Existing User to Multiple/Different Groups via GUI in Linux/Ubuntu?
- Method 1: Adding a User to Multiple/Different Groups Available on the System
- Method 2: Adding a User to Multiple Newly Created Groups
Let’s begin by adding a user to multiple groups.
How to Add an Existing User to Multiple/Different Groups via CLI in Linux/Ubuntu?
A user can be added to multiple groups via the usermod, useradd commands, and by editing /etc/group file by using CLI (Command Line Interface) by the below-explained methods:
Method 1: Add an Existing User to Multiple/Different Groups via the “usermod” Command
The “usermod” is used to modify/update the user account. The command either adds or appends the users to the targetted groups. It depends on the options being used with the command. Let’s see how it works:
To add an existing user “linuxgenieuser1” to multiple groups: group1, group2, and group3, run the following command:
sudo usermod -G group1,group2,group3 linuxgenieuser1
Where the “G” flag adds the users in the selected secondary groups.
The above output verifies that that user linuxgenieuser1 is added in group1, group2, and group3.
Alternatively, to verify the groups along with group IDs to which the user linuxgenieuser1 is added, execute the following command:
id linuxgenieuser1
The above output indicates that the user linuxgenieuser1 is a member of groups: linuxgenieuser1 (primary group), group1, group2, and group3 with group IDs 1010, 1003, 1004, and 1005 respectively.
Whereas, to add an existing user to multiple new groups along with keeping the user in previously added groups, i.e, append user groups, run the following command:
sudo usermod -a -G group1,group2,group3 linuxgenieuser1
Where:
- -a: append.
- -G: add the users in the selected secondary groups.
The above output indicates that the user linuxgenieuser1 is added in group1, group2, and group3.
Method 2: Add an Existing User to Multiple/Different Groups via /etc/group File
The /etc/group is a configuration file that contains group definitions. The/etc/group file is edited to add an existing user to several groups. To add an existing user linuxgenieuser1 to group1, group2, and group3, first launch any editor, for example, Nano text editor by executing the following command:
sudo nano /etc/group
The above command launches the /etc/group file in the Nano text editor as shown below:
Scroll to the end of the file and locate the groups: group1, group2, and group3. Then, edit the file by typing the username, i.e., linuxgenieuser1 ahead of these group names as shown below:
Save the file and Exit the Nano text editor by pressing Ctrl+O and Ctrl+X respectively.
The output in the above figure verifies the addition of linuxgenieuser1 in group1, group2, and group3.
Method 3: Add a New User to Multiple/Different Groups via the “useradd” Command
The useradd command can be used to create a new user account and add it to multiple groups. For example, to create a new user, linuxgenieuser1 and it in groups1, group2, group 3, execute the following command:
sudo useradd linuxgenieuser1 -G group1,group2,group3
Where the “G” flag adds the users in the selected groups.
To verify the addition of user: linuxgenieuser1 in specified groups, execute the following command:
groups linuxgenieuser1
The above output indicates that the user: linuxgenieuser1, is added in multiple groups, i.e., group1, group2, and group3.
Method 4: Add Multiple Existing Users in Multiple/Different Groups
The usermod command does not support the addition of multiple users in a group. However, via the bash environment, a for-loop can be utilized to iterate the users and add multiple users in multiple groups. For example, execute the following command to add the users linuxgenieuser1 and linuxgenieuser2 to group1, group2, and group3:
for u in {linuxgenieuser1,linuxgenieuser2}; do sudo usermod -a -G group1,group2,group3 $u; done
The above output indicates that the users linuxuser1 and linuxuser2 are added in group1, group2, and group3.
That’s all about adding a user into multiple groups via CLI in Linux/Ubuntu. Next, adding a user into multiple groups via GUI in Linux/Ubuntu is demonstrated.
How to Add an Existing User to Multiple/Different Groups via GUI in Linux/Ubuntu?
The GUI (Graphical User Interface) offers a graphical and user-friendly way of interaction between a user and a system. Users who are new to Linux/Ubuntu prefer to use GUI. A user can be added to multiple groups via GUI by the below-described methods:
Method 1: Adding a User to Multiple/Different Groups Available on the System
To add a user “linuxgenieuser1” to multiple groups available on the system: group1, group2, and group3 via GUI, follow the below-mentioned steps:
Step 1: Update System Repositories
To update the system repositories, execute the following command:
sudo apt update
Step 2: Install the “gnome-system-tools” Package
The default manager of Ubuntu 22.04 does not provide any option to configure users and groups. Therefore, to configure users and groups, the gnome-system-tools package is required to be installed.
The gnome-system-tools contain cross-platform configuration utilities. To install gnome-system-tools, execute the following command:
sudo apt install gnome-system-tools
The above output indicates the successful installation of the gnome-system-tools package.
Step 3: Add a User to Multiple Groups
To add users to multiple groups, launch the “Users and Groups” application that was installed with gnome-system-tools in the previous step as shown below:
First, select the user, i.e., “linuxgenieuser1” and then click “Manage Groups” as shown below:
A “Group settings” pop-up window is opened. Select the group from the “Groups available on the system”. For example, group1, and then press Properties:
A “Group ‘group1 Properties” pop-up window is opened. Select the user/group member from the list that is to be added in group1, i.e., linuxgenieuser1, and a checkmark on it to add the user, linuxgenieuser1 in group1:
Similarly, add linuxgenieuser1 in group2 and group3 by following the same procedure.
Step 4: Verify a User Added to a Group
To verify, which users are part of a group, select a group from the list of groups available on the system, for example, group1, and click “Properties”:
A “Group ‘group1’ Properties” pop-up window is opened. The tick mark beside the user linuxgenieuser1 signifies that it has been added to the group group1:
Method 2: Adding a User to Multiple Newly Created Groups
To add a user “linuxgenieuser1” to multiple newly created groups available on the system: group4, group5, and group6 via GUI, follow the below-mentioned steps:
Step 1: Add a User to Multiple Newly Created Groups
First, select the user, i.e., “linuxgenieuser1” and then click “Manage Groups” as shown below:
A “Group settings” pop-up window is opened. Press the “Add” button:
There is a prompt for authentication as a new group is being created. Enter the password for authentication:
A “New group” pop-up window is opened. First type the name of the group, e.g., group4. The Group ID is generated automatically. Next, checkmark the user to be added, i.e., linuxuser1.
This creates a new group, group4, and adds the user linuxgenieuser1 to it. Similarly, create new groups, group5, and group6, and add the user linuxgenieuser1 to these groups.
When a new group is created it is added in groups available on the system section in “Group settings” and can be viewed each time the pop-up window “Group settings” is launched as shown below:
Step 2: Verify a User Added to a Group
To check if a user is part of a certain group, for example, group4, first, select the group group4 from the list of groups, and click “Properties”:
A “Group ‘group4’ Properties” pop-up window is opened. The tick mark beside the user linuxgenieuser1 signifies that it has been added to the group group4:
That’s all about adding an existing user into multiple groups.
Conclusion
A user can be added to multiple groups via the usermod, useradd commands, by editing /etc/group file, and via GUI. Both usermod and userdd commands add a user in multiple groups. The usermod command adds an existing user to multiple groups while the useradd command creates a new user and adds it to multiple groups. On the other hand, the existing user is added to multiple groups by manually editing the /etc/group file to enter the user’s names against specific groups. Moreover, the GUI offers convenience to beginner Linux/Ubuntu users but requires the installation of a third-party application. A user can choose among these methods depending on his/her requirements.
This article demonstrated different methods to add an existing user to multiple groups in Linux/Ubuntu.



















