Pcornel
Browse topics
Options
Recent
Favorites
Command · Linux

restorecon

restorecon

Reset SELinux file contexts to the labels defined by the active labeling policy.

Execution context

Target Linux host · SELinux policy/label context

Use when

Primary lookup intent: configure. Use `restorecon` when the lookup goal is to reset SELinux file contexts to the labels defined by the active labeling policy. Tie the result to the same host, namespace, user identity and time window as the symptom.

Then verify

Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Repeat the original workload/request before closure.

Privilege User may relabel owned accessible files where policy permits; system paths normally require root.State impact Changes stateProduction Unknown

Operational impact: Recovery class: reversible. Before-state for `restorecon`: Capture current SELinux labels plus expected policy mapping for the exact paths before relabeling. STATE CHANGE — `restorecon` can modify persistent or runtime state. Scope the target, capture before-state and verify after-state. `restorecon` safety classification: changes_state — persistent or runtime state change that should be preceded by a baseline and followed by verification.
Command detailsSafety model · family · platform · verification · bundle
PrivilegeUser may relabel owned accessible files where policy permits; system paths normally require root.
Execution contextTarget Linux host · SELinux policy/label context
State impactChanges state
Safe during productionUnknown
CategorySELinux
Evidence levelmixed
Primary DomainLinux
Technically verified2026-08-29
Family Inux
PlatformLinux
PrerequisiteTarget Linux host · SELinux policy/label context
Output fields

Field glossary

Important fields projected from persisted Command guidance.

Expected-state cue for `restorecon`

Target files read back with the policy-derived expected SELinux labels. Capture the exact invocation, exit status, stdout/stderr, target identity and observation time.

Command → Topic semantics

Used in these Topics

Each relation carries both placement role and operational semantic: verifies, configures, troubleshoots, collects evidence, changes state or general.

DomainsLinux

Find another Command

Reference enrichment

Evidence boundary

What this output can establish — and where you must not over-claim.

Proves

Supports the state directly exposed by restorecon for the selected object and execution context.

Does not prove

Does not by itself prove root cause, adjacent dependency health, effective end-to-end behavior, return-path health or workload recovery.

Next check

Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Repeat the original workload/request before closure.

Depth when you need it

Command guidance

Execution context

Target Linux host · SELinux policy/label context

Use when

Primary lookup intent: configure. Use restorecon when the lookup goal is to reset SELinux file contexts to the labels defined by the active labeling policy. Tie the result to the same host, namespace, user identity and time window as the symptom.

Important fields

Expected-state cue for restorecon: Target files read back with the policy-derived expected SELinux labels. Capture the exact invocation, exit status, stdout/stderr, target identity and observation time.

Common problems

Suspicious-output cue for restorecon: Labels remain wrong, custom mappings are missing, filesystem/context prevents relabel, or denials continue for another reason. Treat this as a troubleshooting signal, not automatic root cause.

Operational impact

Recovery class: reversible. Before-state for restorecon: Capture current SELinux labels plus expected policy mapping for the exact paths before relabeling. STATE CHANGE — restorecon can modify persistent or runtime state. Scope the target, capture before-state and verify after-state. restorecon safety classification: changes_state — persistent or runtime state change that should be preceded by a baseline and followed by verification.

Runtime cautions

Rollback for restorecon: Reapply the captured custom label only if it was intentionally non-policy state; otherwise correct persistent semanage mappings and relabel. Failure recovery: If access changes unexpectedly, compare AVCs, policy mapping and previous labels, then restore the intended persistent context model. Prerequisites for restorecon: Confirm the expected SELinux file-context rule first; do not relabel merely to silence a denial without proving label drift. Confirm enforcing mode, exact object/path, current label/policy source and audit evidence before changing labels or policy mappings. Privilege boundary for restorecon: User may relabel owned accessible files where policy permits; system paths normally require root. Confirm distribution/tool version and effective namespace before relying on option-specific behavior.

Technical context

Post-change verification for restorecon: Verify effective labels/policy and rerun the original confined workload access. Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: configure. Safety class: changes_state. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. restorecon is documented as an operational lookup primitive under SELinux. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.

Command Output Deep Dive

Variants · known-good and broken output

Read the stored sample against its authored expected state and interpretation, then return to the Command evidence boundary for what the observation can and cannot prove.

Known-good · 1Broken · 1Transitional · 1Observed · 0
1 · Observe the exact persisted fields/state.2 · Compare with authored known-good, broken or transitional samples.3 · Apply the Command evidence boundary; output is not end-to-end proof.4 · Run the next discriminating check and repeat the original workload/test when relevant.
Known-good state patternKnown-good · Linux
State pattern: expected object is present, identity/scope matches the controlled test, terminal state is healthy and relevant counters/results are internally consistent.
Expected state

healthy/terminal

Interpretation

restorecon — Known-good. State pattern: expected object is present, identity/scope matches the controlled test, terminal state is healthy and relevant counters/results are internally consistent. Why: this command exposes Linux kernel/userspace resource path state. What it proves: only the selected object/context and fields directly returned here. What it does not prove: root cause, adjacent dependency health or end-to-end workload success. Next check: Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Then repeat the original workload/request and verify the return path.

Evidence boundary

Supports the state directly exposed by restorecon for the selected object and execution context.

Does not prove: Does not by itself prove root cause, adjacent dependency health, effective end-to-end behavior, return-path health or workload recovery.
Next check

Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Repeat the original workload/request before closure.

Transitional state patternTransitional · Linux
State pattern: object exists but negotiation, convergence, reconciliation, retry or recovery is still progressing; timers/counters or stage markers should change between samples.
Expected state

in-progress

Interpretation

restorecon — Transitional. State pattern: object exists but negotiation, convergence, reconciliation, retry or recovery is still progressing; timers/counters or stage markers should change between samples. Why: this command exposes Linux kernel/userspace resource path state. What it proves: only the selected object/context and fields directly returned here. What it does not prove: root cause, adjacent dependency health or end-to-end workload success. Next check: Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Then repeat the original workload/request and verify the return path.

Evidence boundary

Supports the state directly exposed by restorecon for the selected object and execution context.

Does not prove: Does not by itself prove root cause, adjacent dependency health, effective end-to-end behavior, return-path health or workload recovery.
Next check

Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Repeat the original workload/request before closure.

Broken state patternBroken · Linux
State pattern: expected object is absent, denied, unresolved, failed or divergent from the controlled test; error/result fields identify the directly observed boundary, not automatic root cause.
Expected state

failed/degraded

Interpretation

restorecon — Broken. State pattern: expected object is absent, denied, unresolved, failed or divergent from the controlled test; error/result fields identify the directly observed boundary, not automatic root cause. Why: this command exposes Linux kernel/userspace resource path state. What it proves: only the selected object/context and fields directly returned here. What it does not prove: root cause, adjacent dependency health or end-to-end workload success. Next check: Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Then repeat the original workload/request and verify the return path.

Evidence boundary

Supports the state directly exposed by restorecon for the selected object and execution context.

Does not prove: Does not by itself prove root cause, adjacent dependency health, effective end-to-end behavior, return-path health or workload recovery.
Next check

Inspect the exact process namespace/credentials/cgroup and owning kernel subsystem, then test the resource from the original workload context. Repeat the original workload/request before closure.

Confirmation

Confirm action

Continue?