Labels
Cheat sheet · https://pcornel.dk/topic.php?topic=2859
Answer
SELinux labels are stored in each file's extended attributes and assigned by policy rules (file contexts), at creation or by restorecon. Ports and other objects have labels too.
Remember
Default labels come from semanage fcontext rules; restorecon applies them. Ports: semanage port -l. A full relabel (/.autorelabel) fixes widespread label problems.
First checks
matchpathcon <path>— default context for a pathgetenforce / 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
Verify in this order
policy file-context rules → labels assigned → domains access by 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=2859