CertGrid CertGrid
Hands-on Lab·Red Hat Certified System Administrator

Restoring Default SELinux Contexts

The objective says "restore default file contexts", and the exam question behind it is always the same: a service cannot read files in a directory it should be able to. The fix is two commands, and the tempting one-command version silently comes undone.

Security and SELinux Guide 57 of 67 Intermediate

semanage fcontext edits policy; restorecon relabels files. Neither does the other's job, and both are needed. chcon changes a file without changing policy, so the next restorecon - or a filesystem relabel - reverses it.

Every command on this page runs on RHCSA-A01.
Server NameIP AddressOSRolesCPURAMHDD
RHCSA-A01192.168.0.31RHEL 10.0Practice node (graded) - spare /dev/sda2 Core4 GB50 GB + 15 GB

This guide includes

Use this because the exam asks it as a real denial rather than as a command. This matters because chcon works and is still the wrong answer - only a relabel from the policy survives.

Before you start

  1. A real denial

  2. The rule, and then the relabel

  3. Why not `chcon`

Official sources