hardMultiple ChoiceObjective-mapped
XK0-006 Practice Question: An Apache web server (httpd) is serving content…
An Apache web server (httpd) is serving content from a custom directory /webapps/company. The root directory is labeled with the default_t context, causing httpd to be denied access. Which command should the administrator use to persistently relabel the directory for httpd access?
⚠ Common exam trap
It's easy for candidates to confuse `chcon` (immediate but non-persistent) with `semanage fcontext` (persistent via policy), or they incorrectly assume `restorecon` can change the context to a non-default type when it only restores the type defined in the policy.
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
✓
semanage fcontext -a -t httpd_sys_content_t '/webapps/company(/.*)?'
`semanage fcontext` modifies the SELinux file context policy persistently, and the regex `/webapps/company(/.*)?` ensures the rule applies to the directory and all its contents. This is necessary because `restorecon` (option A) only applies the default context from the policy, which is `default_t` for this custom path, and `chcon` (option B) is non-persistent and will be overwritten by a file system relabel. The `setsebool` (option C) controls a boolean for user content, not the file context of a custom directory.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
restorecon -v /webapps/company
Why it's wrong here
restorecon applies the default context from the policy, but if no custom rule was added, it will revert to default_t.
- ✗
chcon -t httpd_sys_content_t /webapps/company
Why it's wrong here
chcon changes the context immediately but does not survive a restorecon or filesystem relabel.
- ✗
setsebool -P httpd_read_user_content on
Why it's wrong here
This boolean allows httpd to read user home directories, not custom paths.
- ✓
semanage fcontext -a -t httpd_sys_content_t '/webapps/company(/.*)?'
Why this is correct
This sets the persistent default SELinux type for the directory and its contents.
Go deeper
Related to this question
Learn chapter
File Permissions and Ownership
Key term
Policy
A policy is a set of rules or guidelines that defines how an organization manages, secures, and operates its IT systems and services.
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.
About these practice questions
One of 979 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 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.