EX200 Manage users and groups Practice Question
An administrator is migrating user accounts to a new system. They want to preserve the user's primary group name and GID. Which commands should be used in sequence?
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
✓
groupadd --gid <GID> <group> && useradd -g <group> <user>
To preserve the primary group name and GID during migration, you must first create the group with the desired GID using `groupadd --gid <GID> <group>`, then create the user with that group using `useradd -g <group> <user>`. Option A fails because the group does not exist; Option B fails for the same reason if the group is new; Option D is not a valid shell command sequence because 'then' is not a command.
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 -u <UID> -g <group> <user>
Why it's wrong here
The -u flag in useradd specifies the user's UID, not the group's GID, and -g requires an existing group name or GID. Without running groupadd first, the command fails if <group> is not already defined in /etc/group. Additionally, this command does not attempt to create a group with the desired GID, so it cannot achieve the migration goal.
- ✗
useradd -g <group> <user>
Why it's wrong here
This command omits any attempt to create the group; useradd -g only assigns an existing primary group. If <group> does not already exist in /etc/group, useradd exits with an error before any user is created. There is also no way to enforce a particular GID for the group, since groupadd is never invoked.
- ✓
groupadd --gid <GID> <group> && useradd -g <group> <user>
Why this is correct
This is the correct sequence because groupadd --gid explicitly creates the group with the requested GID, and the && operator ensures the subsequent useradd runs only if groupadd succeeds. The useradd -g then sets that newly-created group as the user's primary group. This atomic two-step chain guarantees both objects exist with the intended numeric GID.
- ✗
groupadd -g <GID> <group> then useradd -g <group> <user>
Why it's wrong here
The intended order is correct, but the word 'then' is not a valid shell command separator. The shell will attempt to execute a command named 'then', causing a syntax error or confusing behavior, so the two commands are never chained properly. To make this work, you would need to replace 'then' with '&&' or ';', which is why this answer is not acceptable.
Go deeper
Related to this question
About these practice questions
One of 427 original EX200 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.