SELinux
Cheat sheet · https://pcornel.dk/topic.php?topic=2854
Answer
SELinux is mandatory access control on RHEL-family systems: every process and file has a security context, and the policy decides which domains may access which types, regardless of Unix permissions.
Remember
Never disable SELinux to fix a problem: read the AVC denial and fix the label (restorecon, semanage fcontext), boolean (setsebool -P) or port (semanage port). Use permissive mode only briefly to confirm.
First checks
getenforce / sestatus— mode and policyls -Z <path>— file contextps -eZ | grep <proc>— process contextausearch -m AVC -ts recent— recent denialssemanage fcontext -l | grep <path>— context rules for a path
Commands
getenforce- Return the current SELinux enforcement mode as Enforcing, Permissive or Disabled.
sestatus- Summarize SELinux enablement, policy, enforcement mode and related filesystem state.
restorecon- Reset SELinux file contexts to the labels defined by the active labeling policy.
semanage- Manage persistent SELinux policy mappings such as ports, file contexts, users and booleans.
Verify in this order
process domain and file type → policy rule checked → allowed or AVC denial logged
Where it usually breaks
First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2854