XK0-006 Security Practice Question
A system administrator needs to ensure that the Apache web server can read files in /var/www/html, which has the SELinux context httpd_sys_content_t. However, Apache is unable to access the files. What command should be used to apply the correct context to the directory and its contents?
⚠ Common exam trap
Many exam-takers assume the context is missing and choose `chcon` or `semanage fcontext` to set it, when in fact the context is already present but not applied correctly, and `restorecon` is the proper tool to enforce the policy-defined context.
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
✓
restorecon -Rv /var/www/html
The directory /var/www/html already has the correct SELinux type (httpd_sys_content_t) as stated, but Apache cannot access the files. This suggests that the file contexts are not correctly applied or are mislabeled. The restorecon -Rv command resets the SELinux context of the directory and its contents to the default policy-defined context (httpd_sys_content_t), ensuring consistent labeling. This directly resolves the access issue without needing to define or change the context type.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
chcon -R -t httpd_sys_content_t /var/www/html
Why it's wrong here
chcon changes context directly but is not persistent across relabels; restorecon is better.
- ✓
restorecon -Rv /var/www/html
Why this is correct
Correct. restorecon applies the default context recursively.
- ✗
fixfiles -R restore /var/www/html
Why it's wrong here
fixfiles is used for full filesystem relabel, not for specific paths.
- ✗
semanage fcontext -a -t httpd_sys_content_t /var/www/html
Why it's wrong here
This modifies policy defaults but does not immediately apply changes; requires restorecon.
Visual reference
Go deeper
Related to this question
About these practice questions
This XK0-006 question is part of Courseiva's 979-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 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.