auditd
Configuration File
The main configuration file for auditd is located at:
/etc/audit/auditd.confThis file controls the behavior of auditd itself, including log writing, log rotation, and how auditd responds to disk space shortages or errors.
# Log writing behaviorflush = INCREMENTALfreq = 20
# Log rotationnum_logs = 5max_log_file = 6max_log_file_action = ROTATE
# Dispatcherdisp_qos = lossydispatcher = /sbin/audispdname_format = NONE
# Disk space thresholdspace_left = 75
# The "_action" options determine how errors or disk space issues should be handled:admin_space_left_action = SUSPENDdisk_full_action = SUSPENDdisk_error_action = SUSPENDNote
max_log_fileis measured in MB.num_logsonly takes effect whenmax_log_file_actionis set toROTATE.- Modern Linux distributions (such as RHEL 9 and Ubuntu 24.04) have integrated the functionality of
audispdintoauditd. As a result, some systems no longer run a separateaudispdprocess, although the configuration option may still exist for compatibility.
Audit Rules
Audit Rules can be divided into three categories:
-
Control Rules — Control the behavior of the Linux Audit Framework.
-
File Watch Rules (also referred to as File System Rules) — Audit specific files or directories.
-
System Call Rules — Audit specific system calls.
Modern Linux distributions typically recommend placing custom rules under:
/etc/audit/rules.d/*.rulesThen run:
augenrules --loadto automatically generate and load:
/etc/audit/audit.rulesAlthough editing audit.rules directly is still supported, using the rules.d directory is the recommended approach because it is easier to maintain and manage.
Example Rules
# ----------------------------# Control Rules# ----------------------------
# Delete all existing rules-D
# Kernel backlog queue size## Increase the buffers to survive stress events.## Make this bigger for busy systems-b 8192
# Set failure mode# 0 = silent# 1 = printk# 2 = panic-f 2
# ----------------------------# File Watch Rules# ----------------------------
-w /etc/passwd -p wa -k passwd_changes-w /etc/group -p wa -k group_changes-w /etc/shadow -p wa -k shadow_changes-w /etc/sudoers -p wa -k sudoers_changesWhere:
| Option | Description |
|---|---|
-w | Watch a specific file or directory |
-p | Permission types (r, w, x, a) |
-k | Assign a key to the rule for easier searching with ausearch -k |
Permission flags:
| Flag | Meaning |
|---|---|
r | Read |
w | Write |
x | Execute |
a | Attribute Change (such as chmod, chown, and touch) |
For example:
ausearch -k passwd_changesFurther Reading: What is auditd?
In Linux, almost every security-related operation is ultimately handled by the Kernel.
For example:
- User login or logout
- Running
sudo - Executing a program
- Modifying
/etc/passwd - Changing file permissions (
chmod) - Deleting files
- Creating new processes
These operations are eventually translated into one or more System Calls, which are processed by the Linux Kernel.
To support security auditing and compliance requirements, the Linux Kernel provides a built-in Linux Audit Framework that records security-related events.
auditd (Linux Audit Daemon) is the userspace daemon that works with this framework.
Its responsibilities include:
-
Receiving Audit Events generated by the Kernel
-
Writing events to
/var/log/audit/audit.log -
Managing log rotation
-
Forwarding events to other plugins or logging systems (such as rsyslog or a SIEM platform)
The workflow can be summarized as follows:
System Call / File Change │ ▼Linux Kernel (Audit Framework) │ Generate Audit Event │ ▼ auditd │ ▼/var/log/audit/audit.logIn general, the process works like this:
-
The administrator loads Audit Rules.
-
The Linux Kernel monitors system activity according to those rules.
-
When a rule is matched, the Kernel generates an Audit Event.
-
auditd receives the event and writes it to
/var/log/audit/audit.log. -
Administrators use tools such as
ausearchandaureportto search or analyze the logs.
The responsibilities of each component are summarized below:
| Component | Function |
|---|---|
| Linux Audit Framework | A kernel subsystem that generates Audit Events based on configured Audit Rules. |
| auditd | Receives Audit Events and writes them to audit logs. |
| auditctl | Dynamically manages Audit Rules stored in the Kernel. |
| augenrules | Merges and loads rules from /etc/audit/rules.d/. |
| ausearch | Searches Audit Logs based on specified criteria. |
| aureport | Generates summary reports from Audit Logs. |
Understanding this architecture makes it easier to explain several common behaviors.
For example:
-
Why do changes made with
auditctltake effect immediately?- Because
auditctlupdates the Audit Rules stored in the Kernel directly, rather than modifying configuration files.
- Because
-
Why do rules disappear after a reboot?
- Because rules added with
auditctlexist only in memory. They must be reloaded from configuration files after the system starts.
- Because rules added with
-
Why can the Kernel continue generating Audit Events even if auditd is stopped?
- Because auditing is performed by the Linux Kernel. Without auditd, there is simply no userspace daemon available to receive and write those events to disk.
A simple way to remember the Linux Audit System is:
Audit Rules tell the Kernel what to monitor; the Kernel detects events; auditd records them; and tools like
ausearchandaureporthelp you analyze them.