XK0-005 · Question #284
While trying to access a website hosted on the server, the systems administrator receives the following error message: The administrator then performs some diagnostics: Which of the following…
The correct answer is D. restorecon /var/www/html/website/index.html. To resolve website access issues caused by incorrect SELinux contexts, the restorecon command should be used to apply the default security contexts to files and directories within the web server's document root. This ensures that the web server process has the necessary…
Question
While trying to access a website hosted on the server, the systems administrator receives the following error message:
The administrator then performs some diagnostics:
Which of the following commands should the administrator use to fix the issue?
Options
- Achown -R www:www /var/www/website
- Cchmod -R 777 /var/www/website
- Drestorecon /var/www/html/website/index.html
How the community answered
(24 responses)- A17% (4)
- C8% (2)
- D75% (18)
Why each option
To resolve website access issues caused by incorrect SELinux contexts, the `restorecon` command should be used to apply the default security contexts to files and directories within the web server's document root. This ensures that the web server process has the necessary permissions to access the website's content according to SELinux policy.
`chown -R www:www /var/www/website` changes file ownership, which is relevant for traditional permissions but does not address SELinux context issues if ownership is already correct or if the problem specifically stems from SELinux.
`chmod -R 777 /var/www/website` grants full read, write, and execute permissions to all users, which is a major security risk and would only address traditional file permission issues, not SELinux contexts.
The `restorecon` command restores the default SELinux security contexts for files and directories. If a website is inaccessible due to "Permission denied" errors even with correct traditional file permissions and ownership, it often indicates an incorrect SELinux context preventing the web server from accessing the files. `restorecon` re-applies the policy-defined contexts, resolving such issues.
Concept tested: SELinux context restoration for web services
Source: https://man7.org/linux/man-pages/man8/restorecon.8.html
Topics
Community Discussion
No community discussion yet for this question.