In high-security enterprise environments and production Linux server deployments, system administrators and compliance auditors must maintain tamper-resistant logs of system activities. Standard application logs in /var/log capture high-level service events but fail to record low-level kernel activities—such as unauthorized modifications to sensitive configuration files (like /etc/shadow or /etc/ssh/sshd_config), execution of unauthorized binaries, or privilege escalation system calls.
The Linux Audit Daemon (auditd) operates at the kernel level, providing granular monitoring and auditing capabilities. By hooking directly into the Linux kernel audit subsystem, auditd records specific system calls, tracks read and write accesses to critical files, logs command execution by specific user IDs, and generates immutable audit trails necessary for compliance frameworks such as PCI-DSS, SOC 2, and ISO 27001.
Installing auditd on Ubuntu Server
The audit subsystem is built into the Ubuntu Linux kernel, but user-space daemon utilities must be installed from package repositories:
- Update the local APT package index and install
auditdalong with its companion auditing libraries:
sudo apt update && sudo apt install -y auditd audispd-plugins
- Verify that the audit service is active and enabled to start on system boot:
sudo systemctl status auditd
sudo systemctl enable auditd
Understanding Audit Rules and Rules Configuration
Audit rules are categorized into three types: control rules (daemon configuration), filesystem rules (file and directory watches), and system call rules (kernel calls). Permanent audit rules are maintained in /etc/audit/rules.d/audit.rules.
To inspect currently active rules loaded in the kernel:
sudo auditctl -l
Configuring File Watches for Sensitive Assets
To audit every attempt to read, write, execute, or change attributes on critical system files, configure file watch rules:
- Open the audit rules configuration file in your text editor:
sudo nano /etc/audit/rules.d/audit.rules
- Add file watches using the
-w(watch path),-p(permissions), and-k(search key) syntax:
# Track modifications to user account and password databases
-w /etc/passwd -p wa -k identity_changes
-w /etc/shadow -p wa -k identity_changes
-w /etc/group -p wa -k identity_changes
-w /etc/gshadow -p wa -k identity_changes
# Track alterations to SSH daemon configuration
-w /etc/ssh/sshd_config -p wa -k sshd_config_changes
# Track execution of privilege escalation binaries
-w /bin/su -p x -k priv_escalation
-w /usr/bin/sudo -p x -k priv_escalation
The wa permission flag monitors write (w) and attribute changes (a), while x monitors execution.
- Load the new rules into the active kernel audit engine without rebooting:
sudo augenrules --load
Searching and Analysing Audit Logs with ausearch
The raw audit log file is maintained at /var/log/audit/audit.log. Because raw kernel entries are dense and verbose, use the ausearch utility to query events by key, timestamp, or command:
- To search for all security events tagged with the
identity_changeskey:
sudo ausearch -k identity_changes
- To search for all failed system calls or access denials within the last 24 hours:
sudo ausearch -ts today -sv no
- To interpret numeric user IDs (UIDs) and system calls into readable human names:
sudo ausearch -k sshd_config_changes -i
Generating Executive Audit Reports with aureport
The aureport utility processes raw audit logs into concise tabular summaries:
- To view an overview summary of all recorded security events:
sudo aureport --summary
- To generate an audit report of all file modifications:
sudo aureport -f -i
- To review all user authentications and login attempts:
sudo aureport -u -i
Implementing auditd on Ubuntu Server ensures comprehensive accountability, providing non-repudiable proof of system modifications across your infrastructure.