To add an existing user to a secondary group, use the usermod command followed by the -G option and the name of the group:

sudo usermod -a -G groupname seba

For example, to add the user seba to a group named sudo you’ll need to run the following command:

sudo usermod -a -G sudo seba

How to Add an Existing User to Multiple Groups in One Command

sudo usermod -a -G group1,group2 seba

How to Remove a User From a Group

sudo gpasswd -d seba groupname

How to Create a Group

sudo groupadd groupname

How to Delete a Group

sudo groupdel groupname

How to Change a User’s Primary Group

sudo usermod -g groupname seba

How to Create a New User and Assign Groups in One Command

sudo useradd -g users -G wheel,developers seba

Display User Groups

id seba

groups seba