Remove a User from a Group

Remove User from Group

Question

Which of the following commands can remove a user from a group?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

E

The correct answer is E. usermod.

Explanation: The usermod command in Linux is used to modify user account details, including the user's primary group membership. The -G option is used to modify secondary group membership.

To remove a user from a group, you need to use the -G option followed by a comma-separated list of groups that the user should be a member of. If you want to remove a user from a group, you simply omit the group from the list.

For example, if you want to remove the user "john" from the group "developers", you would run the following command:

sudo usermod -G adm,dialout,cdrom,sudo,dip,plugdev john

This command removes the user "john" from the "developers" group because the "developers" group is not listed in the command.

Option A, grouprm, is not a valid Linux command. Option B, groupmod, is used to modify group account details, not user accounts. Option C, passwd, is used to change a user's password, not modify group membership. Option D, usergroups, displays the groups that a user is a member of, but does not modify group membership.