How to Enable and Configure auditd in RHEL 10
Enable auditd on RHEL 10: persistent rules with augenrules, watch and syscall rules, immutable mode, auditd.conf, ausearch, aureport, remote logs.
To enable auditd on RHEL 10, confirm the audit package is installed, run systemctl enable --now auditd, put persistent rules in /etc/audit/rules.d/*.rules, and load them with augenrules --load. Check events with ausearch and summaries with aureport, tune log rotation in /etc/audit/auditd.conf, and lock the rules with -e 2 in production.
This guide is part of our RHEL 10 setup series and goes deep on one control from our RHEL 10 hardening checklist: recording security-relevant events with the Linux Audit system. Commands follow Red Hat's RHEL 10 security hardening documentation and the audit man pages (auditctl(8), audit.rules(7), auditd.conf(5)).
Key takeaways
- auditd writes kernel audit events to
/var/log/audit/audit.log. It records what happened; it does not block anything. - Rules typed with
auditctlare lost at reboot. Persistent rules go in/etc/audit/rules.d/and are compiled byaugenrules. - Restart auditd with
service auditd restart; the systemd unit refuses manual stops so that auditing cannot be switched off casually. - Tag every rule with
-kso you can search withausearch -k. - Start from the sample rule sets shipped with the audit package and OpenSCAP profiles instead of writing everything from scratch.
The audit tools at a glance
| Tool or file | Purpose |
|---|---|
auditd | Daemon that receives events from the kernel and writes the log |
auditctl | Add, list and delete rules in the running kernel; show status |
augenrules | Merge files in /etc/audit/rules.d/ into /etc/audit/audit.rules and load them |
ausearch | Search the audit log by key, user, time, event type and more |
aureport | Summary reports: logins, authentications, executables, anomalies |
/etc/audit/auditd.conf | Daemon settings: log location, size, rotation, disk full actions |
/etc/audit/plugins.d/ | Plugins such as syslog forwarding and remote logging |
Step 1: Check that auditd is installed and running
auditd is installed and enabled on a default RHEL 10 installation. Confirm it:
rpm -q audit
systemctl status auditd
sudo auditctl -s
auditctl -s shows enabled 1 when auditing is active, plus the backlog limit and how many events were lost. If the package is missing, install and enable it:
sudo dnf install -y audit
sudo systemctl enable --now auditd
To capture events from processes that start before auditd, add audit=1 to the kernel command line. On larger systems also raise the early backlog with audit_backlog_limit:
sudo grubby --update-kernel=ALL --args="audit=1 audit_backlog_limit=8192"
Step 2: Understand the two kinds of rules
| Rule type | Syntax | Example use |
|---|---|---|
| File watch | -w path -p rwxa -k key | Changes to /etc/passwd or /etc/ssh/sshd_config |
| System call | -a always,exit -F arch=b64 -S syscall -F field=value -k key | Commands run with root privileges, file deletions, time changes |
Permissions in -p are r (read), w (write), x (execute) and a (attribute change). On 64-bit systems, write syscall rules for both arch=b64 and arch=b32 so 32-bit calls are not missed.
Step 3: Try rules temporarily with auditctl
sudo auditctl -w /etc/passwd -p wa -k identity
sudo auditctl -l
sudo useradd testaudit
sudo ausearch -k identity -i
The -i flag turns numeric IDs into names. These rules disappear at reboot or when rules are reloaded, which makes auditctl good for testing.
Step 4: Write persistent rules
Create a rule file in /etc/audit/rules.d/. Files are processed in name order, so number them.
sudo tee /etc/audit/rules.d/50-local.rules <<'EOF'
## Identity and authentication files
-w /etc/passwd -p wa -k identity
-w /etc/group -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/gshadow -p wa -k identity
## Privilege configuration
-w /etc/sudoers -p wa -k privilege
-w /etc/sudoers.d/ -p wa -k privilege
## SSH server configuration
-w /etc/ssh/sshd_config -p wa -k sshd_config
-w /etc/ssh/sshd_config.d/ -p wa -k sshd_config
## Commands run as root by logged-in users
-a always,exit -F arch=b64 -S execve -F euid=0 -F auid>=1000 -F auid!=unset -k root_cmd
-a always,exit -F arch=b32 -S execve -F euid=0 -F auid>=1000 -F auid!=unset -k root_cmd
## System time changes
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time_change
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime -k time_change
## Loading kernel modules
-a always,exit -F arch=b64 -S init_module,finit_module,delete_module -k modules
EOF
The auid (audit user ID, also called the login UID) stays the same after sudo or su, so these events show which person ran a root command, not only that root ran it. auid!=unset drops events from system processes that never logged in.
Load and verify:
sudo augenrules --check
sudo augenrules --load
sudo auditctl -l
Recording every root execve on a busy server produces a lot of data. Watch log volume for a few days and narrow rules if needed.
Use the shipped sample rules
The audit package ships sample rule files for common baselines (such as STIG, OSPP and PCI-DSS) and helper files like a base configuration and a finalize file. Depending on the audit version, they are under /usr/share/audit-rules/ or /usr/share/doc/audit/rules/; run rpm -ql audit audit-rules 2>/dev/null | grep rules to find them on your system. Copy the ones you need into /etc/audit/rules.d/ and adjust.
Step 5: Make the rules immutable
Add a final file so nobody, including root, can change audit rules without a reboot:
echo "-e 2" | sudo tee /etc/audit/rules.d/99-finalize.rules
sudo augenrules --load
After this, auditctl changes fail until the next boot. Do this only once your rules are tested, and remember that rule changes on these hosts now need a reboot window.
Step 6: Configure the daemon
Key settings in /etc/audit/auditd.conf:
| Setting | What it controls | Typical choice |
|---|---|---|
log_file | Log path | /var/log/audit/audit.log |
max_log_file | Size in MB before action | Sized to your disk and retention policy |
max_log_file_action | What happens at that size | ROTATE, or KEEP_LOGS when you ship and prune logs elsewhere |
num_logs | Rotated files to keep with ROTATE | Enough to cover your retention period |
space_left / space_left_action | Warning when free disk gets low | EMAIL or SYSLOG |
admin_space_left_action | Action when disk is critically low | SUSPEND or SINGLE on strict systems |
disk_full_action | Action when disk is full | Depends on whether availability or audit completeness matters more |
Put /var/log/audit on its own filesystem on servers that must keep complete audit trails, so a full /var does not stop auditing. Apply changes with:
sudo service auditd restart
Step 7: Search and report
# All identity changes today, readable
sudo ausearch -k identity -ts today -i
# Root commands by a specific login user
sudo ausearch -k root_cmd -ua 1001 -i
# Failed logins
sudo ausearch -m USER_LOGIN --success no -i
# SELinux denials in the last 10 minutes
sudo ausearch -m AVC -ts recent
# Summary report and specific reports
sudo aureport --summary
sudo aureport -au # authentication attempts
sudo aureport -l # logins
sudo aureport -x --summary # executables
sudo aureport -k --summary # events by rule key
A single action often produces several records (SYSCALL, PATH, CWD, PROCTITLE) that share an event ID. ausearch -i groups them so you can read the whole event. The PROCTITLE record holds the full command line.
Reading a raw audit event
Without -i, a watch rule hit on /etc/passwd produces records like these (shortened):
type=SYSCALL msg=audit(1762500902.481:2284): arch=c000003e syscall=257 success=yes exit=3 ppid=4120 pid=4188 auid=1001 uid=0 gid=0 euid=0 comm="useradd" exe="/usr/sbin/useradd" key="identity"
type=CWD msg=audit(1762500902.481:2284): cwd="/root"
type=PATH msg=audit(1762500902.481:2284): item=0 name="/etc/passwd" inode=1835 nametype=NORMAL
type=PROCTITLE msg=audit(1762500902.481:2284): proctitle=7573657261646400746573746175646974
| Field | Meaning |
|---|---|
audit(1762500902.481:2284) | Epoch timestamp and event serial number; records with the same pair belong to one event |
syscall=257 | System call number (openat on x86_64); ausearch -i shows the name |
auid=1001 | The original login user, even though uid=0 shows it ran as root |
exe, comm | The program that made the call |
key | The -k tag from your rule |
proctitle | Full command line, hex-encoded when it contains spaces or nulls; -i decodes it |
Reducing noise
Some rules generate many events you do not need. Exclude them early with never rules placed before the broader rules, or with the exclude filter:
## Drop events from a noisy monitoring agent user (example UID)
-a never,exit -F auid=990
## Do not record CWD records at all
-a always,exclude -F msgtype=CWD
Rules are evaluated in order and the first match wins for exit rules, so a never rule must come before the always rule it is meant to override. Name the file with a low number, such as 10-exclusions.rules.
Choosing rules by goal
| Goal | What to watch | Example key |
|---|---|---|
| Account changes | /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow | identity |
| Privilege changes | /etc/sudoers, /etc/sudoers.d/ | privilege |
| Who ran what as root | execve with euid=0 and a real auid | root_cmd |
| Tampering with logs and audit config | /etc/audit/, /var/log/audit/ | audit_config |
| Kernel changes | init_module, finit_module, delete_module | modules |
| Unauthorised file access attempts | Open calls that fail with EACCES or EPERM | access_denied |
| Application configuration | Your service's config directory | Per application |
For a formal standard (PCI-DSS, a STIG, OSPP), start with the matching sample file or the rules generated from the OpenSCAP profile rather than this table.
Step 8: Send audit logs off the host
Logs stored only on the server can be erased by an attacker who gains root. Forward them to a central system:
- Syslog plugin: set
active = yesin/etc/audit/plugins.d/syslog.confand let rsyslog forward to your SIEM. - audisp-remote: install
audispd-plugins, enable/etc/audit/plugins.d/au-remote.confand set the collector in/etc/audit/audisp-remote.conf. The receiving auditd listens on the port set bytcp_listen_port. - Log agents: Fluent Bit, Filebeat or the Elastic Agent auditd integration can read
audit.logdirectly.
Our comparison of DevOps logging tools can help you choose the collector.
Checking compliance with OpenSCAP
The SCAP Security Guide content in RHEL includes many audit checks. Scan with a profile and review the audit-related failures:
sudo dnf install -y openscap-scanner scap-security-guide
oscap info /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
sudo oscap xccdf eval --profile PROFILE_ID \
--report /tmp/scan-report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
Replace PROFILE_ID with one listed by oscap info. Red Hat notes that a scan result alone does not prove compliance; it is evidence for an auditor to review.
Automating audit configuration
Keep your rule files in Git and deploy them with Ansible so every server gets the same rules. A task that copies files into /etc/audit/rules.d/ and a handler that runs augenrules --load is enough to start. Watch for immutable hosts: the handler fails there until reboot, which is the expected behaviour. See Ansible playbooks used in production for structure, and infrastructure audit tools for wider coverage.
Troubleshooting
| Problem | Cause and fix |
|---|---|
systemctl restart auditd refuses | The unit blocks manual stops. Use service auditd restart. |
| Rules gone after reboot | Added with auditctl only. Put them in /etc/audit/rules.d/ and run augenrules --load. |
Operation not permitted on rule change | Rules are immutable (-e 2). Edit files and reboot. |
lost count rising in auditctl -s | Backlog too small or too many events. Raise -b in rules, narrow noisy rules. |
| Disk filling with audit logs | Rules too broad or rotation unset. Tune max_log_file, num_logs, and forward logs off the host. |
FAQ
Is auditd enabled by default on RHEL 10?
Yes, the audit package is part of a standard installation and the auditd service is enabled. Check with systemctl status auditd and auditctl -s.
Where are audit logs stored?
By default in /var/log/audit/audit.log. The location, size and rotation are set in /etc/audit/auditd.conf.
How do I make audit rules persistent?
Write them in a file ending in .rules under /etc/audit/rules.d/, then run augenrules --load. Rules added only with auditctl are lost at reboot.
Why can't I restart auditd with systemctl?
The auditd unit refuses manual stops so auditing is not switched off casually and the stop is recorded correctly. Use service auditd restart instead.
What does -e 2 do in audit rules?
It makes the audit configuration immutable. No one can add or delete rules until the system reboots, which protects the rules from an attacker with root access.
How do I find who changed a file?
Add a watch rule with a key, such as -w /etc/passwd -p wa -k identity, then run ausearch -k identity -i. The auid field shows the original login user even after sudo.
Does auditd slow down the system?
A focused rule set has little impact. Very broad syscall rules on busy systems can add overhead and large logs, so test rules and watch the lost and backlog counts.
Learn Linux security hands-on
Audit rules, SELinux and hardening are part of our Linux administration training, available in our Kharadi, Pune classroom and live online. Related reading: SELinux in RHEL 10 and SSH keys and security in RHEL 10.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0