Courseiva
hardMultiple ChoiceObjective-mapped

XK0-006 Practice Question: An application is being denied access to a file…

An application is being denied access to a file due to SELinux. Which command can be used to temporarily set the SELinux context of the file to match the expected type for the application?

⚠ Common exam trap

Many exam-takers confuse `chcon` (temporary, immediate change) with `restorecon` (reverts to policy default) or `semanage fcontext` (persistent policy rule that requires an extra step to apply), leading them to pick an option that either disables SELinux or does not immediately fix the file 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

chcon -t httpd_sys_content_t /var/www/html/index.html

The `chcon` command is used to temporarily change the SELinux context of a file without modifying the SELinux policy. By specifying `-t httpd_sys_content_t`, the file's type is set to the expected type for Apache (httpd) to access it, resolving the denial immediately. This change is not persistent across file system relabeling, making it ideal for temporary troubleshooting.

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 -t httpd_sys_content_t /var/www/html/index.html

    Why this is correct

    Changes SELinux context to the specified type.

  • setenforce 0

    Why it's wrong here

    Disables SELinux enforcement, not recommended.

  • restorecon -v /var/www/html/index.html

    Why it's wrong here

    Restores default context, may not fix if context was wrong.

  • semanage fcontext -a -t httpd_sys_content_t /var/www/html

    Why it's wrong here

    Adds a rule, but does not apply immediately.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

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.