102-500 practice question 4 of 30

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

Full set: 233 questions
Answer options
A: grouprm
B: groupmod
C: passwd
D: usergroups
E: usermod Correct answer
Correct Answer:
E. usermod
Explanation

The usermod command is used to modify a user's account details. To manage a user's supplementary group memberships, the -G option is used. To remove a user from a specific group, you must provide a new, complete list of supplementary groups for the user with the -G option, omitting the group from which they should be removed. For example, usermod -G group1,group2 username will set the user's supplementary groups to only group1 and group2, effectively removing them from any others.

Why Incorrect

A. grouprm is not a standard Linux command. The command to remove a group is groupdel.
B. groupmod modifies group properties like name or GID, but is not the primary tool for changing a user's membership in that group.
C. passwd is used to manage user and group authentication information (passwords), not group membership lists.
D. usergroups is not a standard command for modifying group membership.

References

1. usermod(8) Linux manual page. The description for the -G, --groups option states: "If the user is currently a member of a group which is not listed, the user will be removed from the group."

2. Red Hat Enterprise Linux 8 Documentation, "Configuring basic system settings", Chapter 4. Managing local users and groups, Section 4.2.3. "Modifying a user account's group membership". This section provides examples of using usermod -G to change a user's list of supplementary groups.

3. "Linux Administration: A Beginner's Guide, Seventh Edition" by Wale Soyinka (a university-level textbook resource), Chapter 6: "Managing Users and Groups". It details the use of usermod -G for setting the supplementary group list.

Scroll to Top