Secondary groups are the groups that users added after the creations. The primary groups are created during the user creation process. In order to the permissions, there is no difference between them.
This quick tutorial helps you to add an existing user to a secondary group in Linux via the command line.
Advertisement
Example
Use the usermod command-line tool to assign a user to a secondary group. Here you can define multiple group names separate them by a comma.
The following command will add jack to sudo group.
usermod -a -G sudo jack
To make sure, check the entry in /etc/group
file.
cat /etc/group | grep "sudo"
Remove User from Secondary Group
If in case, you have accidentally added a user to a different group or you want to remove another user from the group. The following command will remove user "jack" from the group "sudo".
sudo gpasswd -d jack sudo