Contexts
Cheat sheet · https://pcornel.dk/topic.php?topic=2858
Answer
An SELinux context (label) has user:role:type:level, e.g. system_u:object_r:httpd_sys_content_t:s0. The type is what most policy rules use.
Remember
Files moved with mv keep their old label; copied files get the target directory's label. Set permanent rules with semanage fcontext -a -t <type> '<path>(/.*)?' then restorecon -Rv <path>. chcon changes are lost on relabel.
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
id -Zss -Z
Verify in this order
file label (type) and process domain → policy allows the domain to access the type
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=2858