Use it as the entry point for hardening a Linux server or investigating a security issue.
Security
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).
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.
patched system → minimal services → restricted access → MAC policy → monitoring and alerting
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
Operational reference
Fast context before you go deeper.
sudoPrimary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
Subtopics
Go one level deeper into this subject.
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 HardeningSSH 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 PermissionsFile 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 ACLLinux 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 SELinuxSecurity → 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 AppArmorSecurity → 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 Fail2banFail2ban 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 AuditdAuditd consumes Linux Audit subsystem events and persists/forwards multi-record security events under configured rules, backlog and failure policies for accountable investigation.
Subtopic Linux HardeningLinux 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.
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.
sestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -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
| Layer | Tools | Protects against |
|---|---|---|
| Patching | apt, dnf, unattended upgrades | Known vulnerabilities |
| Identity and authentication | PAM, SSH keys, MFA, sudo | Password guessing, stolen credentials |
| Discretionary access | Permissions, ACLs, umask | Users reading each other's data |
| Mandatory access | SELinux, AppArmor | A compromised service going beyond its role |
| Network | nftables, firewalld, ufw | Unwanted inbound and outbound connections |
| Detection | auditd, journald, fail2ban, a central SIEM | Attacks going unnoticed |
| Service hardening | systemd sandboxing (ProtectSystem=, NoNewPrivileges=) | Limits on what a service can touch |
A baseline for a new server
| Area | Baseline |
|---|---|
| Updates | Automatic security updates, or a defined patch window |
| SSH | Keys only, no root login, limited source networks |
| Accounts | Personal accounts, sudo with logging, no shared logins |
| Services | Only what's needed; listening on the right addresses |
| Firewall | Default-deny inbound |
| MAC | SELinux enforcing, or AppArmor enabled |
| Logging | Persistent journal, forwarded centrally |
| Integrity | Package 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.
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:
| Layer | Controls |
|---|---|
| Identity | PAM, SSH keys, sudo, MFA, central identity (SSSD/FreeIPA/AD) |
| Discretionary access | Owners, mode bits, ACLs, umask |
| Mandatory access | SELinux (RHEL family), AppArmor (Ubuntu/Debian/SUSE) |
| Network | nftables/firewalld/UFW, TCP wrappers (legacy), service binding |
| Integrity & audit | auditd, AIDE, package verification (rpm -Va, debsums) |
| Patching | Unattended updates, kernel live patching |
| Hardening baselines | CIS 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
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
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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.
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.
Quick lookup tables
Security operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Security.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | 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. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin 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 chain | host role + threat boundary → identity/credentials → DAC/PAM/SSH → LSM/firewall/audit policy → effective kernel/userspace enforcement → protected workload → recovery/regression | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | 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. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated 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/regression | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It 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 check | Continue 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 boundary | Security |
|---|---|
| Topic path | Security |
| Runtime state | 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. |
| 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 chain | host 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 boundary | 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. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |