XK0-006 System Management Practice Question
A junior administrator needs to change the ownership of the file /var/www/html/index.html from user 'www-data' to user 'apache' and group 'apache'. Which command will accomplish this?
⚠ Common exam trap
The trap here is mixing up chmod (permissions) with chown (ownership), or using chgrp when both owner and group must change.
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
✓
chown apache:apache /var/www/html/index.html
The chown command with user:group syntax changes both the owner and group of a file. Specifying apache:apache sets the owner and group to apache, fulfilling the requirement. Other commands either modify permissions, change only the group, or modify user account properties rather than file ownership.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
usermod -g apache www-data /var/www/html/index.html
Why it's wrong here
usermod modifies user account attributes, such as a user's primary group, but it does not operate on files. It cannot change the ownership of a specific file. The syntax shown is invalid for file ownership changes. This command would alter the www-data user's primary group, which is not the goal.
- ✓
chown apache:apache /var/www/html/index.html
Why this is correct
chown changes file owner and group. The syntax user:group sets both simultaneously. Using apache:apache sets the owner to apache and the group to apache, exactly as required. This is the standard way to change both ownership attributes in one command, and it requires appropriate privileges (usually root).
- ✗
chmod apache:apache /var/www/html/index.html
Why it's wrong here
chmod changes file mode bits (permissions), not ownership. It does not accept user:group syntax; attempting to use it that way results in an error or misinterpretation. The task requires changing owner and group, which chmod cannot do. Therefore this command is incorrect for the scenario.
- ✗
chgrp apache /var/www/html/index.html
Why it's wrong here
chgrp changes only the group ownership, not the user owner. While it would set the group to apache, it leaves the owner as www-data, failing the requirement to change the owner to apache. A separate chown would still be needed for the user owner.
Go deeper
Related to this question
Learn chapter
File Permissions and Ownership
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
chown
chown is a Linux/Unix command used to change the owner and group associated with a file or directory.
About these practice questions
One of 781 original XK0-006 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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
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.