We can use the usermod command to exclude a user from one or more groups at a time. When using usermod, you must specify which auxiliary groups you want to keep the user in. Let me illustrate with an example.
$ group test users
testuser: testuser testgroup1 testgroup2 root
To remove the user “testuser” from the “testgroup1” and “testgroup2” groups, run the following command (that is, just keep testuser in the “root” group, which is the main “testuser” group):
$ sudo usermod -G root testuser
result
$ group test users
testuser: testuser root directory