$ run as a normal user# run as root (or with sudo)
The quick answer
-w /etc/sudoers -p wa -k sudoers
-w /etc/sudoers.d/ -p wa -k sudoers
-w /etc/passwd -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/ssh/sshd_config -p wa -k sshd_config-w = watch this file, -p wa = on write and attribute change, -k = a key to search by.
Step by step
- auditd is installed and running on RHEL; on Ubuntu:
apt-get install -y auditd. Check:
- **Write rules in
/etc/audit/rules.d/** (quick answer). Watch what matters: identity files, sudo, SSH config, cron, your app's config:
-w /etc/crontab -p wa -k cron
-w /etc/cron.d/ -p wa -k cron
-w /opt/shop/config/ -p wa -k app_config- Load them —
augenrulesbuilds/etc/audit/audit.rulesfrom all files:
augenrules --load
auditctl -l(Do not restart auditd with systemctl restart on RHEL; use augenrules --load or service auditd restart.)
- Search the events —
-iturns numbers into names:
ausearch -k sudoers -i --start today
type=SYSCALL ... comm="vim" exe="/usr/bin/vim" ... auid=alice uid=root ... key="sudoers"auid = the login user (alice), even though she used sudo (uid=root). That is the answer to "who".
- Reports:
aureport -f -i --start this-week | tail
aureport --login --summary -i- Command logging for root (heavy — use with care on busy servers):
-a always,exit -F arch=b64 -S execve -F euid=0 -F auid>=1000 -F auid!=unset -k rootcmd- Protect the trail: ship
audit.logto a central SIEM (Wazuh, Elastic) in near real time; optionally make rules immutable until reboot with a last rule-e 2; size limits in/etc/audit/auditd.conf(max_log_file,num_logs).
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
auditctl -l shows No rules | Rules not loaded. | augenrules --load; check for errors in the rule files. |
| Rules gone after reboot | Added only with auditctl. | Put them in /etc/audit/rules.d/*.rules. |
The audit system is in immutable mode | -e 2 is set. | Change the rule files and reboot. |
| Disk fills with audit logs | Noisy rules (execve for everything). | Narrow rules; set max_log_file and num_logs. |
auid=unset in events | Process started by a service, not a login. | Normal for daemons; filter with auid>=1000. |
| Too many events to read | No keys / no filters. | Always use -k and search with ausearch -k. |
Go further
- Command pages: auditctl, ausearch, audit2allow.
- Next how-tos: Check file integrity with AIDE, See who logged in and when, Find files with risky permissions, Collect security events with Wazuh.
- At work: auditd. SIEM: Wazuh. Kubernetes audit logs: CKS — Audit.
1In an audit event, what is the difference between auid and uid?
auid is the user who logged in (stays the same after sudo); uid is the user the process runs as.
2Where should permanent audit rules be?
In /etc/audit/rules.d/*.rules, loaded with augenrules --load.