LFCS User and Group Management Practice Question
Exhibit
Refer to the exhibit. # useradd -u 1005 -G wheel,dbadmin -m -k /etc/skel newuser useradd: user 'newuser' already exists #
Refer to the exhibit. The administrator attempted to create a user 'newuser' but received an error. Which command should be used to check if the user already exists?
⚠ Common exam trap
A common mix-up: candidates choose a command that seems related to user management (like passwd or usermod) without realizing those commands assume the user already exists and will produce errors or unintended side effects when used for existence verification.
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
✓
cat /etc/passwd | grep newuser
The /etc/passwd file stores all user account information, and using cat to pipe its contents through grep allows the administrator to search for the specific username 'newuser'. If the user exists, grep will output the matching line; if not, no output is returned. This is a standard, quick method to verify user existence without modifying system state.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
cat /etc/passwd | grep newuser
Why this is correct
Searching `/etc/passwd` for the string `newuser` directly confirms whether the account already exists, since local users are recorded there. Piping `cat` into `grep` satisfies the stem's requirement to check for a pre-existing user before retrying `useradd`, which failed because the name was already taken.
- ✗
passwd -S newuser
Why it's wrong here
passwd -S reports password status for an existing account and errors if the user is absent, so it cannot confirm existence. It is tempting because it queries account state, and would be correct when checking whether a known user's password is locked, set or expired.
- ✗
usermod -c newuser
Why it's wrong here
usermod -c sets the GECOS comment field on an existing account; it neither queries nor reports whether 'newuser' exists, and fails outright if the account is absent. It is tempting because usermod does operate on accounts, but it is the tool for modifying an existing user's attributes, not for existence checks.
- ✗
userdel -v newuser
Why it's wrong here
userdel -v removes an account, printing verbose output about the deletion; it does not test for existence and would delete 'newuser' if present. It is tempting because -v produces visible output, but userdel is the account-removal tool, used when decommissioning a user, not for verification.
Go deeper
Related to this question
About these practice questions
This LFCS question is part of Courseiva's 406-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.