easyMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A system administrator wants to create a new user…
A system administrator wants to create a new user and set a password in a single command as part of a provisioning script. Which command accomplishes this?
⚠ Common exam trap
Watch out — candidates often assume `passwd` or `useradd -p` can accept a plaintext password directly, but the exam tests the understanding that these commands require either interactive input or a pre-hashed password, making `chpasswd` the correct choice for a single-command plaintext password set.
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
✓
echo 'user1:password' | chpasswd
The `chpasswd` command reads username:password pairs from standard input, allowing a single command to create or update a user's password. When combined with `echo`, it sets the password for a new or existing user in one line, which is ideal for provisioning scripts. The `-p` option in `useradd` expects an already-hashed password, not a plaintext one, and `passwd` does not accept the password as an argument for security reasons.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
passwd user1 password
Why it's wrong here
passwd does not accept password as argument.
- ✓
echo 'user1:password' | chpasswd
Why this is correct
correctly reads from stdin.
- ✗
useradd -m -p password user1
Why it's wrong here
-p expects encrypted password.
- ✗
usermod -p password user1
Why it's wrong here
usermod does not set password.
Go deeper
Related to this question
Learn chapter
User and Group Administration
Key term
User
A user is any person, system, or device that interacts with an IT service, resource, or identity system, typically authenticated through credentials and authorized to perform specific actions.
Key term
useradd
A command-line utility in Unix-like operating systems used to create a new user account with specified settings.
About these practice questions
Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.