What command can be used to define an SELinux file context rule for a directory?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Prepare for the Red Hat Certified Architect Exam with our comprehensive quiz. Master your skills with multiple choice questions and detailed explanations. Gear up to excel!

Defining an SELinux file context rule for a directory is accomplished through the semanage command. This command modifies the SELinux policy by allowing the user to manage file contexts. In this case, the use of "semanage fcontext -a" followed by the -t option specifies that a new file context type is being added. The type "httpd_sys_content_t" is the SELinux type that permits web server content access, and the expression '/custom(/.*)?' indicates that this rule should apply to the directory named "custom" as well as any files or subdirectories it may contain.

This command effectively instructs SELinux to treat the specified directory and its contents as web server content, which is essential for maintaining proper access control in SELinux-enforced environments where security and access must be tightly controlled.

In contrast, the other options serve different purposes. "setsebool" is used to set SELinux boolean values that toggle specific features or permissions at runtime but does not define file contexts. The "restorecon" command is used to restore the file context of a file or directory to what is defined in the policy, rather than creating a new context. Lastly, "chcon" changes the file context on a

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy