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

Which of the following commands can remove a user from a group?
A . grouprm
B . groupmod
C . passwd
D . usergroups
E . usermod

Answer: E

Explanation:

The usermod command is a utility for modifying user accounts. One of its options is -G, which allows specifying a list of supplementary groups that the user is a member of. If the user is currently a member of a group that is not listed, the user will be removed from that group. For example, to remove the user alice from the group sales, one can use the command sudo usermod -G admin alice,

assuming that alice is only a member of admin and sales groups. Alternatively, one can use the gpasswd command with the –delete option to remove a user from a specific group without affecting other groups. For example, to remove the user alice from the group sales, one can use the command sudo gpasswd –delete alice sales. The other commands in the options are not used for removing a user from a group. The grouprm command does not exist. The groupmod command is used for modifying group attributes, not membership. The passwd command is used for changing user passwords, not groups. The usergroups command is used for displaying the groups that a user belongs to, not modifying them.

Reference: usermod(8) – Linux man page

gpasswd(1) – Linux man page

How to Remove User From Group in Linux [Quick Tip]

Latest 102-500 Dumps Valid Version with 194 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments