An audit trail is a record of actions kept so that someone can later check what happened. Ordinary logs help you debug. Audit records are chosen for accountability: who did what, to which object, when, and whether it succeeded.
What to record
Start with actions that change trust or access:
- logins and failed logins
- changes to users, groups and passwords
- use of elevated privileges
- changes to important configuration files
- changes to the logging and audit setup itself
Recording everything creates noise and fills disks. Choose events that answer a question you actually have.
The Linux audit system
The kernel can produce audit records, and the auditd daemon writes them to disk. The package is usually auditd on Debian and Ubuntu and audit on Fedora and RHEL. Check its state:
$ sudo auditctl -s
enabled 1
pid 612
backlog_limit 8192
lost 0Output is shortened. lost counts records the kernel discarded because its audit queue overflowed, so a growing number means gaps. Containers often cannot manage kernel auditing, so use a virtual machine for practice.
Rules choose events
A watch rule records access to a path:
sudo auditctl -w /etc/passwd -p wa -k identity-w names the path, -p wa selects writes and attribute changes, and -k adds a search label. Rules added this way last until reboot or removal. Persistent rules go in files under /etc/audit/rules.d/. The auditctl man page marks this watch form as deprecated for performance reasons and recommends the syscall rule form, though you will still see it often.
Who really did it
Audit records include auid, the audit user ID (login UID). It is set at login and normally stays the same after sudo or su, so you can tell which person acted even when the command ran as root.
Protect the trail
Limit who can read and change audit logs, plan disk space and rotation, and send copies to another host. Anyone with full control of a machine may be able to stop auditing, so a remote copy matters.
Try it
On a test virtual machine, check sudo auditctl -s and list active rules with sudo auditctl -l. Write down three events you would want recorded and why. The accounts and access files lab shows the files that accounts live in.
Check your understanding
Audit Events
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.