auditd: Linux Audit Logging

Khimananda Oli 8 min read Virtualization
auditd: Linux Audit Logging

By Khimananda Oli | Last reviewed: August 2026

Security breaches often leave traces long before data exfiltration occurs, but only if you are looking in the right place. auditd: Linux Audit Logging provides the kernel-level visibility required to capture these signals, tracking system calls, file access, and privilege escalation that standard application logs miss entirely. For teams preparing for SOC 2 or ISO 27001 audits, this subsystem is not optional; it is the primary source of truth for host-based integrity monitoring and forensic analysis.

How does auditd: Linux Audit Logging actually work?

Understanding the architecture prevents misconfiguration. The Linux Audit Framework operates across three distinct layers: the kernel, the dispatcher, and the userspace daemon. When a process triggers a system call matching an active rule, the kernel generates an audit record. This record passes through the kauditd kernel thread via a netlink socket to the userspace auditd daemon, which writes it to /var/log/audit/audit.log. Unlike application logging, this happens at ring 0, making it extremely difficult for attackers to bypass without rootkit-level access.

Kernel SpaceSyscall Interceptionkauditd ThreadNetlink Socketauditd DaemonEvent FilteringBuffer ManagementLog Storage/var/log/audit/Immutable Records
The auditd: Linux Audit Logging pipeline moves events from kernel interception through the userspace daemon to persistent storage.

This separation matters because the kernel buffer is finite. If auditd cannot consume records fast enough, the kernel queue fills up. Depending on your failure_flag setting in auditd.conf, the system will either silently drop events, print warnings to syslog, or panic the kernel. In production environments handling sensitive data, I typically configure log_format = ENRICHED to resolve UIDs and GIDs at write time, trading slight CPU overhead for significantly faster forensic searches later. Always verify your kernel has audit support enabled (CONFIG_AUDIT=y) before attempting configuration; most modern distributions include this by default, but custom-compiled kernels may omit it.

How do you configure auditd rules for compliance?

Writing effective rules separates useful signal from noise. A common mistake is enabling the sample rules in /etc/audit/rules.d/audit.rules without modification, which generates gigabytes of irrelevant data on busy servers. Instead, build rules targeting specific compliance controls. For SOC 2 Type II, auditors consistently ask for evidence of privileged access monitoring, configuration change tracking, and authentication event logging.

Essential rules for security baselines

Start with these high-value rules that cover 80% of compliance requirements without overwhelming disk I/O. Add them to a custom file like /etc/audit/rules.d/99-custom.rules:

# Monitor privilege escalation
-a always,exit -F arch=b64 -S execve -F euid=0 -F auid!=0 -k priv_esc
-a always,exit -F arch=b32 -S execve -F euid=0 -F auid!=0 -k priv_esc

# Track changes to authentication configuration
-w /etc/passwd -p wa -k identity_changes
-w /etc/shadow -p wa -k identity_changes
-w /etc/sudoers -p wa -k sudo_config
-w /etc/pam.d/ -p wa -k pam_changes

# Monitor SSH configuration modifications
-w /etc/ssh/sshd_config -p wa -k ssh_config_change

# Capture failed permission attempts (potential reconnaissance)
-a always,exit -F arch=b64 -S open,openat,creat,truncate,ftruncate -F exit=-EACCES -k access_denied
-a always,exit -F arch=b64 -S open,openat,creat,truncate,ftruncate -F exit=-EPERM -k access_denied

# Watch critical binary directories
-w /usr/bin/ -p wa -k binary_modification
-w /usr/sbin/ -p wa -k binary_modification

The -k flag assigns a searchable key to each rule. This is non-negotiable for operational efficiency. Without keys, searching requires parsing raw syscall numbers and filtering manually. With keys, ausearch -k priv_esc returns relevant results instantly. Note the auid!=0 filter on privilege escalation rules; this excludes legitimate root cron jobs and systemd services, focusing alerts on interactive sessions where unauthorized escalation actually occurs.

Loading and validating rules

After editing rule files, reload the configuration and verify:

# Load all rules from /etc/audit/rules.d/
sudo augenrules --load

# Verify active rules
sudo auditctl -l

# Check current backlog and rate limits
sudo auditctl -s

If augenrules fails, check syntax carefully. A single malformed line prevents all subsequent rules from loading. Test new rules in staging first; I have seen overly broad execve rules add 15% CPU overhead on database servers running thousands of queries per second. For deeper context on integrating these logs into broader observability, see our guide on structured logging best practices.

System CallProcess ActionRule MatchingCheck arch, syscall,UID, path filtersMatch FoundGenerate RecordAdd Key TagWrite to Log/var/log/audit/No Match → Silent Pass
Auditd rule evaluation determines whether a syscall generates a log record based on configured filters and keys.

How do you search and analyze audit logs effectively?

Raw audit logs are notoriously difficult to read. Each event spans multiple lines with hexadecimal encodings and numeric identifiers. Never parse them with grep in production investigations; use the dedicated tools designed for this format.

Using ausearch for targeted investigations

ausearch understands the multi-line record structure and supports complex filtering:

# Find all privilege escalation events in last 24 hours
sudo ausearch -k priv_esc --start today --format text

# Search for specific user activity by login UID
sudo ausearch -ua 1001 --start 08/01/2026 --end 08/14/2026

# Combine multiple criteria: failed access to /etc/shadow
sudo ausearch -f /etc/shadow -m OPENAT --success no -k access_denied

# Output as CSV for external analysis
sudo ausearch -k identity_changes --format csv > /tmp/identity_audit.csv

The --format text option resolves numeric IDs to human-readable names, while --format raw preserves original values for chain-of-custody documentation. During incident response, I export raw format first for evidence preservation, then re-run with text format for analysis.

Generating compliance reports with aureport

Auditors rarely want raw logs; they want summarized evidence. aureport generates pre-built reports aligned to common compliance frameworks:

# Authentication summary (successful vs failed)
sudo aureport -au --summary --start this-month

# File access report for sensitive paths
sudo aureport -f --summary -i

# Executive summary of all anomalies
sudo aureport --anomaly --summary --start this-week

# User login/logout activity matrix
sudo aureport -l --summary

Schedule these reports weekly via cron and ship them to your centralized logging platform. For teams using the ELK stack, our article on centralized logging with the ELK stack covers ingestion patterns specifically tuned for audit log formats.

How do you tune auditd performance without losing events?

Audit logging consumes resources. On high-throughput systems, unoptimized configurations cause latency spikes or event loss. Balance completeness against performance using these levers.

ParameterDefaultRecommended (Production)Impact
num_logs510–20More rotation files prevent overwriting during incidents
max_log_file8 MB50–100 MBLarger files reduce rotation frequency and IOPS
flushINCREMENTAL_ASYNCSYNC (compliance) / ASYNC (perf)SYNC guarantees writes survive crashes; adds latency
rate_limit0 (unlimited)1000–5000 msgs/secPrevents runaway rules from DoSing the system
backlog_limit819216384–65536Larger queue absorbs burst traffic without drops

Edit /etc/audit/auditd.conf for daemon settings and restart the service. Kernel-side parameters require auditctl:

# Increase backlog limit (survives reboot via rules file)
sudo auditctl -b 32768

# Set rate limit to prevent flooding
sudo auditctl -r 2000

# Monitor current utilization
watch -n 5 'auditctl -s | grep -E "backlog|rate_limit"'

For PCI-DSS or financial systems, set flush = SYNC despite the performance cost. For general infrastructure, INCREMENTAL_ASYNC with a larger backlog provides acceptable durability with minimal overhead. Always benchmark after changes; run fio or your actual workload while monitoring /proc/sys/kernel/audit_backlog to verify queue stability under load.

Compliance Modeflush=SYNC • backlog=65536Zero event loss guaranteedHigher I/O latency (~5-15%)Best for: PCI-DSS, Financial, HIPAAPerformance Modeflush=ASYNC • backlog=16384Minimal overhead (<2%)Possible burst event lossBest for: Dev, Staging, General InfraHybrid RecommendationINCREMENTAL_ASYNC + rate_limit=2000 + key-based filteringBalances durability and throughput for most production workloads
Choosing between compliance and performance modes in auditd: Linux Audit Logging depends on regulatory requirements and workload characteristics.

Implementing auditd: Linux Audit Logging for production readiness

Deploying auditd: Linux Audit Logging successfully requires treating it as infrastructure code, not an afterthought. Store rules in version control, deploy via Ansible or Terraform, and validate configurations in CI pipelines before reaching production. Integrate log shipping immediately; local audit logs provide forensic value but limited operational visibility. Forward enriched records to your SIEM or log aggregation platform using audispd plugins or Fluent Bit for real-time alerting on suspicious patterns.

Test your rules quarterly. Compliance requirements evolve, and stale rules generate false confidence. Run tabletop exercises where team members attempt controlled policy violations and verify detection within expected timeframes. Document exceptions formally; auditors accept justified gaps but reject undocumented ones. If you need assistance designing audit strategies aligned with your specific compliance framework or infrastructure topology, reach out to discuss your environment. Properly configured, auditd transforms opaque Linux hosts into transparent, accountable systems that satisfy both security teams and regulators without sacrificing operational velocity.

Frequently Asked Questions

Auditd is the userspace daemon for the Linux Audit Framework that collects and writes kernel-generated security events to disk for compliance and forensics.

Run sudo apt update followed by sudo apt install auditd audispd-plugins to install the daemon and dispatcher plugins on Ubuntu 24.04 LTS systems.

Default log location is /var/log/audit/audit.log unless changed in /etc/audit/auditd.conf via the log_file directive.

Use ausearch with flags like -m SYSCALL or -k mykey to filter parsed events from binary audit logs efficiently without manual grep parsing.

Auditd captures immutable kernel-level syscalls for compliance while journald handles general application messages; they serve different forensic and operational purposes.

Add -w /etc/passwd -p rwa -k passwd_watch to /etc/audit/rules.d/audit.rules then reload with augenrules --load to activate monitoring.

Yes, excessive syscall rules increase CPU overhead; use rate limiting, exclude noisy paths, and test rules in staging before deploying to production environments.

Set disk_full_action to SUSPEND or HALT in auditd.conf to define behavior when storage fills, preventing silent log loss during incidents.

Configure audisp-remote plugin in /etc/audisp/plugins.d/au-remote.conf to forward real-time audit events over TLS to centralized SIEM platforms.

Run auditctl -l to list active kernel rules and compare output against your intended configuration files to confirm proper rule application.

Monitor user authentication files, privilege escalation commands, and system configuration changes using specific watches and syscall filters mapped to PCI DSS control objectives.

Configure max_log_file_action to ROTATE in auditd.conf and ensure logrotate uses copytruncate or postrotate scripts that signal auditd properly.

Rules added via auditctl are temporary; always write permanent rules to /etc/audit/rules.d/ and regenerate with augenrules --load for persistence across reboots.

Add exclusion rules like -a never,exit -F exe=/usr/bin/specific-binary before watch rules to reduce volume from known safe high-frequency processes.

Yes, auditd starts automatically on RHEL 9 with baseline rules; verify status with systemctl is-active auditd and review /etc/audit/rules.d/ for defaults.