A system administrator notices that the Apache web server cannot serve content from a newly created directory, /var/www/extras, even though the standard Linux file permissions are correct. Running ls -Z /var/www/extras reveals the directory has the SELinux context unconfined_u:object_r:default_t:s0. The administrator needs to quickly grant the web server access to this directory for testing purposes, without making a change that will persist through a file-system relabel. Which command will accomplish this?
restorecon -R /var/www/extras
chmod -R 755 /var/www/extras
semanage fcontext -a -t httpd_sys_content_t "/var/www/extras(/.*)?"
The correct command is chcon -R -t httpd_sys_content_t /var/www/extras. The chcon command changes the SELinux security context of a file or directory, and the -R option ensures the change is applied recursively to the directory and all existing files so Apache can read them. Because chcon only modifies the on-disk extended attribute, the change is temporary and will be overwritten by a relabel or by running restorecon.
semanage fcontext -a -t httpd_sys_content_t "/var/www/extras(/.*)?" is incorrect because it writes a persistent rule to the policy, causing the label to survive relabel operations, which the scenario expressly avoids.
restorecon -R /var/www/extras is incorrect; it resets the context to the policy default (likely default_t), leaving Apache unable to read the content.
chmod -R 755 /var/www/extras changes only UNIX permissions (DAC) and has no effect on SELinux MAC labeling.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is SELinux, and why is it relevant in this scenario?
Open an interactive chat with Bash
What is the difference between `chcon` and `semanage fcontext`?
Open an interactive chat with Bash
Why doesn't `restorecon` fix the access issue in this context?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access