Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Security

Direct answer

Linux security combines layers: patching, minimal services, users and sudo, file permissions and ACLs, SSH hardening, PAM, a host firewall, mandatory access control (SELinux/AppArmor), auditing and intrusion blocking (fail2ban).

When to use this

Use it as the entry point for hardening a Linux server or investigating a security issue.

First 30 seconds

1. Updates current? apt list --upgradable / dnf check-update --security.

2. Exposure: ss -tulpn and the firewall rules.

3. Logins: SSH key-only, no root password login (sshd -T).

4. MAC framework enforcing: getenforce / aa-status.

5. Audit and log forwarding in place.

Operational verification

patched system → minimal services → restricted access → MAC policy → monitoring and alerting

Evidence · next step

For Security, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Security. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commandsudo
Scope / prerequisiteUse it as the entry point for hardening a Linux server or investigating a security issue.
Reference · 1
What next?3 suggested next steps
Child topics (this level)9
Catalog command links1
Evidence1
On this pageJump to a specific section
Linux command reference

Primary Commands

Configuration and operational commands for this Topic.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

host role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regression

Healthy evidence: required controls are loaded/enforcing, intended allowed operations work, intended denied operations are blocked and auditable, and workload/recovery behavior remains healthy

Step 2 Commands Verify boundary
ss -tulpn
last -n 10
sudo grep -i 'failed' /var/log/auth.log
getenforce || aa-status
Step 3 Verification and output interpretation Verify boundary

Verification path. Reproduce using the exact identity, service, path/object label and execution context. Separate authentication success from subsequent authorization. For SELinux/AppArmor, correlate denial records with current mode/profile/labels and confirm the access vector/path actually matches the failing operation. For hardening, verify both the intended denial and one required allowed workflow. Audit presence supports reconstruction but is not equivalent to evidence that policy blocked the action.

Verification chain. host role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regression

Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: policy exists only on disk, enforcement is permissive/unloaded, credentials or privilege paths bypass intent, audit is incomplete, or the workload remains exposed despite a green control status

Step 5 Common mistakes Narrow the fault
  • Disabling SELinux/AppArmor to make something work.
  • Unused services left listening.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Drill down

Subtopics

Go one level deeper into this subject.

Subtopic PAM

PAM is the Linux authentication/account/session/password stack used by PAM-aware services, where module order, control flags, includes and application integration determine the effective decision.

Subtopic SSH Hardening

SSH Hardening reduces remote-access exposure by proving effective sshd policy, host/user authentication, authorization, algorithm choices, forwarding limits, privilege boundaries and key lifecycle against the actual SSH workload.

Subtopic File Permissions

File Permissions covers Linux DAC decisions from process UID/GIDs and pathname traversal through inode ownership and rwx/special mode semantics, with effective access verified as the real workload identity.

Subtopic ACL

Linux ACLs extend discretionary permissions with named users/groups, default ACLs and an effective mask that can limit entries beyond what their displayed permissions suggest.

Subtopic SELinux

Security → SELinux explains SELinux as one component of Linux security, emphasizing mode, loaded policy, subject/object contexts and AVC decisions without replacing the dedicated SELinux operational branch.

Subtopic AppArmor

Security → AppArmor explains AppArmor as a path-oriented Linux Security Module and how attached profiles, execution transitions and enforcement mode participate in a layered access decision.

Subtopic Fail2ban

Fail2ban observes authentication/application logs and applies temporary actions such as source-address firewall bans after configured thresholds, reducing repeated automated abuse without replacing authentication hardening.

Subtopic Auditd

Auditd consumes Linux Audit subsystem events and persists/forwards multi-record security events under configured rules, backlog and failure policies for accountable investigation.

Subtopic Linux Hardening

Linux Hardening applies role- and distribution-specific secure configuration across boot/kernel, identities, services, SSH/PAM, storage, LSMs, firewall, audit, updates, secrets and recovery while controlling drift.

Key points

Start with exposure: what listens and who can log in. Keep the system patched automatically or on a schedule. Never fix access problems by disabling SELinux/AppArmor or the firewall — find the specific rule.

Key checks
  • sestatus / aa-status — SELinux or AppArmor state
  • ss -tulpn — listening services
  • journalctl -u sshd -g 'Failed' — failed logins
  • ausearch -m avc,user_login -ts today — audit events (auditd)
ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Security is resolved only when the intended allow/deny behavior is demonstrated for the real identity and workload, effective controls are confirmed loaded/enforcing, and adjacent recovery paths still work.

In depth

Linux host security: layers and a baseline

Linux security is a set of layers, each covering what the others miss:

  • discretionary access control (users, groups, permissions, ACLs);
  • mandatory access control (SELinux or AppArmor);
  • authentication (PAM, SSH keys, sudo);
  • network filtering;
  • auditing and monitoring.

The selinux(8) manual page describes the mandatory layer as a flexible mandatory access control architecture. It's enforced by the kernel regardless of file permissions, so a compromised service is still limited to what its policy allows.

Layers and their tools

LayerToolsProtects against
Patchingapt, dnf, unattended upgradesKnown vulnerabilities
Identity and authenticationPAM, SSH keys, MFA, sudoPassword guessing, stolen credentials
Discretionary accessPermissions, ACLs, umaskUsers reading each other's data
Mandatory accessSELinux, AppArmorA compromised service going beyond its role
Networknftables, firewalld, ufwUnwanted inbound and outbound connections
Detectionauditd, journald, fail2ban, a central SIEMAttacks going unnoticed
Service hardeningsystemd sandboxing (ProtectSystem=, NoNewPrivileges=)Limits on what a service can touch

A baseline for a new server

AreaBaseline
UpdatesAutomatic security updates, or a defined patch window
SSHKeys only, no root login, limited source networks
AccountsPersonal accounts, sudo with logging, no shared logins
ServicesOnly what's needed; listening on the right addresses
FirewallDefault-deny inbound
MACSELinux enforcing, or AppArmor enabled
LoggingPersistent journal, forwarded centrally
IntegrityPackage verification (rpm -Va, debsums), auditd rules for key files

Quick security check of a host

host$ sudo apt list --upgradable 2>/dev/null | grep -c security; sudo dnf updateinfo list --security 2>/dev/null | wc -l
host$ sudo sshd -T | grep -E "^(permitrootlogin|passwordauthentication) "
host$ sudo ss -tulnp | awk 'NR>1 && $5 !~ /127.0.0.1|\[::1\]/ {print $5, $7}'
host$ getenforce 2>/dev/null || sudo aa-status --enabled && echo apparmor-on
host$ sudo nft list ruleset | grep -m1 "policy drop"
host$ systemd-analyze security --no-pager | head -6
host$ awk -F: '$3 == 0 {print $1}' /etc/passwd

systemd-analyze security

This command rates each service by how much of systemd's sandboxing it uses, from "OK" to "UNSAFE". It's a fast way to find services that run with full privileges, without needing to. Hardening options such as ProtectSystem=strict, PrivateTmp=yes and NoNewPrivileges=yes then lower the exposure.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Security is part of Security. Linux Security is the platform-security reference for tracing identity, authentication, discretionary and mandatory access control, host hardening, audit and trust from configured policy to effective kernel/userspace enforcement and the protected workload.

Runtime state ownership and mechanics. Linux security composes authentication (PAM and service mechanisms), identity/credentials, DAC permissions/ACLs, capabilities, LSM policy such as SELinux/AppArmor, audit and service/network policy. These controls are cumulative: passing one layer does not bypass another. SELinux labels/types and AppArmor path/profile rules differ in policy model, while auditd records selected security-relevant events rather than making authorization decisions.

Topic-specific state model. Linux Security is the platform-security reference for tracing identity, authentication, discretionary and mandatory access control, host hardening, audit and trust from configured policy to effective kernel/userspace enforcement and the protected workload.

Interpretation rule. - File ownership or sudo access ≠ complete Linux security posture.

  • A control reporting enabled ≠ the intended process, object, session or network flow is actually constrained.

Quick reference

Linux security works in layers; each closes a different gap:

LayerControls
IdentityPAM, SSH keys, sudo, MFA, central identity (SSSD/FreeIPA/AD)
Discretionary accessOwners, mode bits, ACLs, umask
Mandatory accessSELinux (RHEL family), AppArmor (Ubuntu/Debian/SUSE)
Networknftables/firewalld/UFW, TCP wrappers (legacy), service binding
Integrity & auditauditd, AIDE, package verification (rpm -Va, debsums)
PatchingUnattended updates, kernel live patching
Hardening baselinesCIS benchmarks, DISA STIG, OpenSCAP
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --report /tmp/cis.html /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Security is resolved only when the intended allow/deny behavior is demonstrated for the real identity and workload, effective controls are confirmed loaded/enforcing, and adjacent recovery paths still work.

Model. chmod 777 cannot override LSM or read-only mount policy. Disabling SELinux/AppArmor to make an error disappear only localizes a policy boundary and can hide the real label/profile defect. PAM success does not show sudo, filesystem or application authorization. Fail2ban acts on observed authentication patterns and network banning; it does not fix authentication policy. Security controls should remain explicit layers rather than a single “permission denied” bucket.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Configuration intent and lifecycle. Harden one control with a known access/recovery path and preserve the policy source of truth. PAM stack order/control flags matter; sudo/SSH hardening can lock out administration; SELinux policy should normally be fixed through correct labels/booleans/policy rather than permanent disablement; AppArmor profiles should move from complain to enforce only after reviewing legitimate workload behavior. Audit rules need bounded scope to avoid volume/resource problems.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Security. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.kernel.org/security/index.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
linux securitylinux hardening securitylinux host security
Embedded reference data

Quick lookup tables

Security operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Security.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateLinux Security is the platform-security reference for tracing identity, authentication, discretionary and mandatory access control, host hardening, audit and trust from configured policy to effective kernel/userspace enforcement and the protected workload.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainhost role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regressionTrace requested/configured state through effective state to the observed workload result.
Failure boundarySecurity closes only when the intended allow/deny behavior is demonstrated for the real identity and workload, effective controls are proven loaded/enforcing, and adjacent recovery paths still work.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux security/trust evidence can establish this proof path: host role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regressionUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. Security closes only when the intended allow/deny behavior is demonstrated for the real identity and workload, effective controls are proven loaded/enforcing, and adjacent recovery paths still work.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks.Continue to the next unresolved boundary while preserving the original test condition.

Security · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundarySecurity
Topic pathSecurity
Runtime stateLinux Security is the platform-security reference for tracing identity, authentication, discretionary and mandatory access control, host hardening, audit and trust from configured policy to effective kernel/userspace enforcement and the protected workload.
Fast checks- Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Security. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check.
Verification chainhost role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regression Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundarySecurity closes only when the intended allow/deny behavior is demonstrated for the real identity and workload, effective controls are proven loaded/enforcing, and adjacent recovery paths still work. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?