AIDE (Advanced Intrusion Detection Environment) is the open-source workhorse for file integrity monitoring on Linux. It builds a baseline of hashes and metadata for every file you care about, then compares the running system to the baseline on a schedule. Tuned right, the daily report is one screen of changes you can scan in 30 seconds. Tuned wrong, it is a 50-megabyte HTML attachment no one ever opens. This article is about the tuning.
How to verify
Confirm the package is installed, the database exists, and a recent check ran:
sudo dpkg -l aide aide-common # apt -V aide | head
sudo ls -la /var/lib/aide/
sudo aide --check 2>&1 | tail -30
sudo systemctl list-timers --all | grep aide
sudo journalctl -u dailyaidecheck.service --since "7 days ago"
A baseline at /var/lib/aide/aide.db.gz and a daily systemd timer (named dailyaidecheck.service on Debian/Ubuntu) is the steady state. If both are present and the last run completed without errors, AIDE is doing its job.
What’s happening
AIDE walks every file under the paths in aide.conf, computes one or more hashes (SHA-256, SHA-512, RIPEMD-160), records metadata (permissions, owner, size, ACLs, capabilities, xattrs), and stores everything in a single compressed database. A --check run repeats the walk and diffs the results against the baseline. Any added, removed, or changed file appears in the report.
The output explodes when the rules are not selective. Watching /var/log/ with strict file-size checking produces a daily report dominated by “every log file grew” entries. The right model is a tiered rule set: stricter for /bin, /sbin, /usr/bin, /etc; relaxed for /var/log/; ignore /tmp, /proc, /sys, /run, and the runtime directories of database engines.
The baseline database is the high-value secret. An attacker who can update aide.db.gz can also update the file they backdoored without triggering an alert. Store the baseline read-only, ideally on a separate volume mounted read-only, with a copy on a write-once external store. The check itself can run with a copy at /var/lib/aide/aide.db while the source of truth lives offline.
The procedure
- Install.
sudo apt install aide aide-common(Debian/Ubuntu) orsudo dnf install aide(RHEL family). The package on Debian sets up the daily timer automatically. - Edit the policy.
/etc/aide/aide.conf(Debian) or/etc/aide.conf(RHEL). Reduce noise by adding!^/var/lib/postgresqland similar negative rules under the body, and by relaxing the rule for log paths:/var/log f+p+u+g+s(file presence, perms, owner, group, size — no content hash). - Define rule macros at the top.
STRICT = p+i+u+g+n+s+m+S+sha256+rmd160,LSPP = p+i+u+g+n+S+sha256,LOGS = p+u+g+s. Then apply:/bin STRICT,/sbin STRICT,/usr/bin STRICT,/etc STRICT,/var/log LOGS. - Build the initial database.
sudo aideinit -y -f(Debian) orsudo aide --init && sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz(RHEL). The first run can take several minutes on a busy host. - Move the baseline off the box.
sudo cp /var/lib/aide/aide.db.gz /mnt/backup/aide-baseline-$(hostname)-$(date +%F).db.gzand replicate to a read-only store. Keep one copy on the local host for fast checks; the offline copy is the source of truth. - Schedule the check. On Debian/Ubuntu, the
dailyaidecheck.timerships pre-enabled. On RHEL family, create/etc/cron.daily/aide-check:#!/bin/sh\n/usr/sbin/aide --check 2>&1 | mail -s "AIDE $(hostname) $(date)" ops@example.com. - Update the baseline after legitimate changes.
sudo aide --update && sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gzafter a deploy or package update. Commit the rationale to your change log so the next operator knows why the baseline moved. - Route the report somewhere humans look. Email it to a ticket queue, post the diff to Slack, or have the systemd unit exit non-zero on findings and let your monitoring catch the failure.
Common pitfalls
- The
aide.db.gzbaseline is plain gzipped data — readable to anyone who can read the file. Limit permissions to0600 root:rootand audit access (auditd rule on the path). - A daily check on a large filesystem (TB-scale) can take hours. Tune the rule set or split the policy into smaller scopes and check them on staggered schedules.
- Symbolic links are watched by default — a link target change without a content change is reported. Add the
lattribute to track link targets explicitly; remove it to ignore. - AIDE has no concept of “this file legitimately rotated” — log rotation produces phantom “file removed” + “file added” entries every cycle. Either exclude rotated logs or use a relaxed rule that ignores content hashes.
- Updating the database from a compromised host writes the attacker’s malicious file as a legitimate baseline. Always verify the integrity of the source binary (
apt verify,rpm -V) beforeaide --update.
In the engagements we run, AIDE is paired with auditd: any change AIDE flags is correlated to a user, process, and time via the audit log. That cross-reference lives in Managed Operations — file integrity monitoring without context is just noise.