Using semanage for context management

The semanage command writes the new context to the SELinux policy, which is used to apply the file context at the relabeling of the file labels or while setting the default file context using restorecon. It uses an extended regular expression to specify the path and filenames for applying those rules (new file context). The most commonly used extended regular expression with semanage fcontext is (/.*)?. This expression matches the directory listed before the expression and everything in that directory recursively.

An example of semanage command usage is shown in the following diagram:

The semange command ...

Get CentOS Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.