Linux

Question

Remove A User From the specific Group In Linux

By samueltarcin9999 ·
How can I remove a specific user from the group?
Thread display: Collapse - | Expand +

All Answers

Collapse -

How can I remove a specific user from the group?

by rvkanth1996 In reply to Remove A User From the sp ...

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

Related Discussions

Related Forums