Courseiva

LFCS User and Group Management Practice Question

Which two commands can add an existing user to a supplementary group?

⚠ Common exam trap

Candidates often confuse `usermod -G` (which replaces all supplementary groups) with `usermod -aG` (which appends), leading them to select `usermod -G` alone as correct, or they mistakenly think `useradd -G` can modify an existing user.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

gpasswd -a

Option B, gpasswd -a, is correct because gpasswd with the -a (add) flag adds an existing user to a named supplementary group, e.g. `gpasswd -a alice developers`, modifying /etc/group without altering the user's primary group. Option E, usermod -aG, is correct because usermod with -G specifies supplementary groups and the -a (append) flag ensures the listed group is added to the user's existing supplementary group set rather than replacing it, e.g. `usermod -aG developers alice`. Option A, useradd -G, is wrong here because useradd creates new accounts and its -G flag sets supplementary groups only at account-creation time, so it cannot add an already-existing user. Option C, addgroup, is wrong because it is a Debian/Ubuntu convenience script for creating a new group (and optionally adding a user at creation), not the standard command for adding an existing user to an existing supplementary group. Option D, groupmod, is wrong because it modifies a group's attributes such as its name (-n) or GID (-g), and does not manage user membership.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    useradd -G

    Why it's wrong here

    useradd creates a new account and its -G flag sets supplementary groups only at creation, so it cannot modify an existing user. It tempts because the -G syntax looks like group assignment, and would be correct when provisioning a brand-new user with supplementary groups.

  • ✓

    gpasswd -a

    Why this is correct

    gpasswd -a user group appends the user to the named group's member list in /etc/group, granting supplementary membership without altering the primary group. It edits group membership directly, complementing usermod -aG which does the same via the user's entry.

  • ✗

    addgroup

    Why it's wrong here

    addgroup creates a new group or, in its interactive form, changes a user's primary group; it does not append an existing user to a supplementary group. It tempts because it manages group membership, and would be correct when creating a fresh group on Debian-based systems.

  • ✗

    groupmod

    Why it's wrong here

    groupmod edits a group's own attributes, such as its name or GID; it cannot add a user to a group's membership. It tempts because it manipulates groups directly, and would be correct when renaming an existing group or changing its numeric identifier.

  • ✓

    usermod -aG

    Why this is correct

    usermod -aG group user appends the group to the user's supplementary group list; the -a flag is essential, since omitting it replaces all existing supplementary memberships. This satisfies adding an existing user to an additional group while preserving current ones.

About these practice questions

One of 406 original LFCS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.