Courseiva
mediumMultiple ChoiceObjective-mapped

XK0-006 Practice Question: A web server on RHEL 8 is serving content from a…

A web server on RHEL 8 is serving content from a non-default directory /data/web. The SELinux context is set to default_t for the directory, causing access denials. Which command should be used to set the correct context for web content?

⚠ Common exam trap

The Linux+ exam often tests the distinction between temporary (`chcon`) and persistent (`semanage fcontext`) context changes, and candidates mistakenly choose `chcon` because it works immediately but fails after a relabel or restorecon.

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 "/data/web(/.*)?"

`semanage fcontext` modifies the SELinux file context policy persistently, and the regular expression `/data/web(/.*)?` ensures that the directory and all its contents are labeled with `httpd_sys_content_t`, which is the type required for web content served by Apache. This persistent change survives file system relabeling, unlike `chcon` which only sets a temporary context.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • setsebool -P httpd_can_network_connect on

    Why it's wrong here

    Controls network access, not file context.

  • restorecon -R /data/web

    Why it's wrong here

    Restores context based on policy, but policy may still have default_t.

  • chcon -t httpd_sys_content_t /data/web

    Why it's wrong here

    Changes context immediately but does not survive relabeling.

  • semanage fcontext -a -t httpd_sys_content_t "/data/web(/.*)?"

    Why this is correct

    Adds default context to policy, ensuring persistence after restorecon.

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 →

How Courseiva writes practice questions · Editorial policy

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.