AIDE File Integrity Monitoring: Detect Unauthorized Changes on Linux
Deploy AIDE (Advanced Intrusion Detection Environment) to build a cryptographic baseline of your Linux filesystem and automatically alert on unauthorized modifications — a core control for compliance and breach detection.
Dylan H.
Tutorials
August 3, 2026
9 min read
Prerequisites
Linux server running Ubuntu 22.04/24.04, Debian 12, or RHEL/Rocky 9
Root or sudo access
Basic familiarity with the Linux command line
Optional — a mail relay or SMTP server for alert emails
Introduction
One of the quietest signs of a breach is a modified system file. An attacker who has gained a foothold will often alter binaries, add cron jobs, plant SSH keys, or tamper with /etc/passwd — all without triggering firewall rules or noisy network events. File Integrity Monitoring (FIM) catches exactly this class of activity.
AIDE (Advanced Intrusion Detection Environment) is a mature, open-source FIM tool that builds a cryptographic database of your filesystem at a known-good point in time. On every subsequent check, it compares the live filesystem against that baseline and reports every change — added files, deleted files, and altered attributes like permissions, ownership, size, and hash values.
This guide walks through installing and configuring AIDE on a Linux server, automating daily integrity checks, sending email alerts on findings, and integrating the output with a central log pipeline. It is directly applicable to CIS Controls v8 (Control 3.14 — Log Sensitive Data Access) and PCI DSS requirement 11.5.
Prerequisites
Before starting, ensure you have:
A freshly patched Linux server (Ubuntu 22.04/24.04, Debian 12, or RHEL/Rocky 9)
Root or sudo access
postfix or sendmail installed if you want email alerts (optional but recommended)
Enough disk space for the AIDE database — typically 50–200 MB depending on filesystem size
Tip: Run the initial AIDE database build immediately after a clean OS installation and before installing any applications. This gives you the cleanest possible baseline.
The output should show something like Aide 0.18.x or newer.
Step 2 — Review and Customize the Configuration
AIDE's configuration lives at /etc/aide/aide.conf (Debian/Ubuntu) or /etc/aide.conf (RHEL). It defines which directories to monitor and what attributes to check.
Open the config file:
sudo nano /etc/aide/aide.conf
Understanding Rule Groups
AIDE uses named rule groups that combine attribute checks. The default installation ships sensible defaults, but review the key directives:
Security note: Store an offline copy of this database. If an attacker can modify aide.db itself, they can cover their tracks. Consider copying it to read-only storage or a remote server:
On a freshly initialized system, the output should show no changes:
AIDE, version 0.18.x
### All files match AIDE database. Looks okay!
If you have recently updated packages or changed config files since the aideinit, you may see legitimate changes. Review them and — once confirmed safe — update the baseline (covered in Step 7).
Step 5 — Automate Daily Checks with Cron
Create a daily cron job that runs AIDE and emails the output:
sudo nano /etc/cron.d/aide-check
# Run AIDE integrity check daily at 03:15 and mail results to root
15 3 * * * root /usr/bin/aide --check 2>&1 | /usr/bin/mail -s "AIDE Integrity Check: $(hostname) $(date +%F)" root
If you prefer a dedicated script that filters output and only sends mail when changes are detected:
sudo nano /usr/local/sbin/aide-check.sh
#!/usr/bin/env bash# AIDE integrity check — only alert on actual findingsset -euo pipefailAIDE_BIN="/usr/bin/aide"ALERT_EMAIL="security@example.com"HOSTNAME="$(hostname -f)"DATE="$(date +%F)"LOGFILE="/var/log/aide/aide-$(date +%Y%m%d).log"mkdir -p /var/log/aideOUTPUT="$($AIDE_BIN --check 2>&1)"EXIT_CODE=$?echo "$OUTPUT" >> "$LOGFILE"# AIDE exits 0 if no changes, non-zero if there are changes or errorsif [[ $EXIT_CODE -ne 0 ]]; then echo "$OUTPUT" | mail \ -s "[ALERT] AIDE found changes on $HOSTNAME ($DATE)" \ -a "From: aide-monitor@$HOSTNAME" \ "$ALERT_EMAIL" echo "[$(date)] Changes detected — alert sent to $ALERT_EMAIL" >> "$LOGFILE"else echo "[$(date)] No changes detected." >> "$LOGFILE"fi
Step 7 — Update the Baseline After Legitimate Changes
After system updates or intentional config changes, update the AIDE database to avoid false positives on the next check:
# After an apt upgrade or intentional file changes:sudo apt upgrade -y# Rebuild the databasesudo aide --update# Promote the new databasesudo cp /var/lib/aide/aide.db.new /var/lib/aide/aide.db
Workflow tip: Always run aide --update after patch maintenance windows, not before. This records the post-patch state as your new clean baseline.
Step 8 — Protect the AIDE Binary and Database
An attacker who can replace aide itself or tamper with aide.db can make changes invisible. Harden the tooling:
Immutable Flags (Linux ext4/xfs)
# Make the AIDE database immutable — must be removed before updatessudo chattr +i /var/lib/aide/aide.db# Remove before baseline update, then re-applysudo chattr -i /var/lib/aide/aide.dbsudo aide --updatesudo cp /var/lib/aide/aide.db.new /var/lib/aide/aide.dbsudo chattr +i /var/lib/aide/aide.db
Verify the AIDE Binary Hash Manually
sha256sum /usr/bin/aide# Store this output offline for manual verification
Consider AIDE Over SSH (Remote Execution)
For high-security environments, run AIDE from a trusted jump host over SSH so local root cannot tamper with results:
# From a remote admin hostssh -i ~/.ssh/admin-key admin@target-server "sudo aide --check" 2>&1 | tee aide-$(date +%F)-remote.log
Verification and Testing
Test That AIDE Detects Changes
Create a test scenario to confirm AIDE is working:
# 1. Create a test file in a monitored pathsudo touch /etc/aide-test-file.txt# 2. Run AIDE check — it should report the new filesudo aide --check# Expected output includes something like:# f++++++++++++++++: /etc/aide-test-file.txt# 3. Clean upsudo rm /etc/aide-test-file.txtsudo aide --updatesudo cp /var/lib/aide/aide.db.new /var/lib/aide/aide.db
Interpret AIDE Output
The change codes in AIDE output follow this format:
You now have a working AIDE file integrity monitoring setup that:
Builds a cryptographic baseline of your Linux filesystem's known-good state
Detects unauthorized file additions, removals, and modifications — including hash changes, permission changes, and ownership changes
Runs daily checks automatically via cron and only alerts when genuine changes are found
Forwards findings to syslog for SIEM ingestion (Wazuh, Graylog, Loki)
Protects the AIDE database from tampering using immutable file attributes
AIDE directly satisfies several compliance requirements: CIS Controls v8 Control 3.14 (log sensitive data access), PCI DSS 11.5 (deploy a change detection mechanism), and NIST 800-53 SI-7 (software, firmware, and information integrity).