Pcornel
Linux · SELinux

Labels

Cheat sheet · https://pcornel.dk/topic.php?topic=2859

Back to the Topic

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 path
  • getenforce / sestatus — mode and policy
  • ls -Z <path> — file context
  • ps -eZ | grep <proc> — process context
  • ausearch -m AVC -ts recent — recent denials
  • semanage 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

Confirmation

Confirm action

Continue?