The correct action is to change the SELinux context of the file to httpd_log_t. While the file’s standard Linux permissions (664) and ownership (apache) already grant the web server write access, SELinux enforces an additional layer of mandatory access control that blocks writes when the file’s type context does not match what httpd is allowed to target. By setting the context to httpd_log_t, you explicitly label the file as a log that the httpd domain can write to, resolving the denial without disabling SELinux. On the CompTIA Linux+ XK0-005 exam, this scenario tests your understanding that SELinux contexts override traditional permissions—a common trap is to waste time adjusting file ownership or permissions when the real issue is a type mismatch. Remember the mnemonic: “Permissions say yes, but context says no—match the type to let the write flow.”
XK0-005 Security Practice Question
This XK0-005 practice question tests your understanding of security. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Exhibit
Refer to the exhibit.
```
type=AVC msg=audit(1234567890.123:45): avc: denied { write } for pid=1234 comm="httpd" name="app.log" dev=sda1 ino=56789 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:var_log_t:s0 tclass=file
```
Refer to the exhibit. A web application running under Apache cannot write to /var/log/app.log. The file has permissions 664 and is owned by apache. What is the correct action to allow writes while maintaining SELinux policies?
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Change the SELinux context of the file to httpd_log_t.
The file /var/log/app.log has permissions 664 and is owned by apache, so the web server should be able to write to it. However, SELinux is blocking the write because the file's SELinux context does not match the type expected for files that Apache (httpd) is allowed to write to. Changing the SELinux context to httpd_log_t tells SELinux that this file is a log file that httpd can write to, which resolves the denial while keeping SELinux enforcing.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
✗
Change the ownership to root.
Why it's wrong here
Does not address SELinux denial.
✓
Change the SELinux context of the file to httpd_log_t.
Why this is correct
Allows httpd_t to write to that file type.
Related concept
Read the scenario before looking for a memorised answer.
✗
Set the httpd_can_network_connect boolean.
Why it's wrong here
Controls network access, not file writes.
✗
Disable SELinux for the httpd daemon.
Why it's wrong here
Overly permissive and defeats SELinux security.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap here is that candidates see the file is owned by apache with 664 permissions and assume the issue is file ownership or permissions, overlooking that SELinux enforces its own access controls independent of standard Linux permissions.
Detailed technical explanation
How to think about this question
SELinux uses type enforcement to control access; for httpd to write to a file, the file must have a type that httpd is allowed to write to (e.g., httpd_log_t for log files, httpd_sys_content_t for read-only content). The semanage fcontext command can be used to set the default context for a path, and restorecon applies it. In real-world scenarios, administrators often check SELinux denials with ausearch -m avc or sealert to identify the correct type to apply.
KKey Concepts to Remember
Read the scenario before looking for a memorised answer.
Find the constraint that changes the correct option.
Eliminate answers that are true in general but not in this case.
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the XK0-005 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
Related glossary terms
Concepts from this question explained
These glossary pages explain the core terms tested in this XK0-005 question in full detail.
Security — This question tests Security — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Change the SELinux context of the file to httpd_log_t. — The file /var/log/app.log has permissions 664 and is owned by apache, so the web server should be able to write to it. However, SELinux is blocking the write because the file's SELinux context does not match the type expected for files that Apache (httpd) is allowed to write to. Changing the SELinux context to httpd_log_t tells SELinux that this file is a log file that httpd can write to, which resolves the denial while keeping SELinux enforcing.
What should I do if I get this XK0-005 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A server is secured with SELinux in enforcing mode. A custom web application needs to write logs to /var/log/webapp. The SELinux type for httpd is httpd_t. Which command sets the correct context for the log directory?
Why A: Option A is correct because it uses `semanage fcontext` to add a persistent file context rule that assigns the `httpd_log_t` type to the `/var/log/webapp` directory and its contents, then applies it with `restorecon`. The `httpd_log_t` type is specifically designed for log files written by the httpd process, allowing Apache (running as `httpd_t`) to write logs while maintaining SELinux enforcement.
Last reviewed: Jun 25, 2026
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
This XK0-005 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-005 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.