Interview Prep/Linux/Firewalls, MAC & Compliance

Why use `restorecon` instead of `chcon`?

IntermediateProductionFirewalls, MAC & Compliance
Answer

chcon changes a label directly, but the change is lost on the next relabel (restorecon, fixfiles, or a full /.autorelabel). The persistent approach is to define the rule in policy with semanage fcontext -a and then apply it with restorecon. Files moved with mv keep their original label (copies get the destination's default), a classic cause of AVC denials.

All Linux questions Roadmap: Linux

More on Firewalls, MAC & Compliance