Question Locked

Remove A User From the specific Group In Linux

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can I remove a specific user from the group?

1 reply

by rvkanth1996

Use usermod to remove users from the group

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

This discussion is closed to new replies.