Skip to content

The Edge of the Cyber World See the latest

Apps

AIDE File Integrity Monitoring: 13 Steps, 50 Min [2026]

An attacker who gets root rarely announces it. They swap a binary, add a key to authorized_keys, or drop a script into /etc/cron.d, and then they wait. File integrity monitoring (FIM) is the control that notices those edits. This tutorial builds one on Ubuntu with AIDE, the Advanced Intrusion Detection Environment, in 13 steps that take about 50 minutes.

The timing is good. The AIDE project lists 0.19.5 as its current stable release, and its security advisories say versions through 0.19.4 had two detection-bypass bugs: one in how hash values containing a null byte were compared, and one in how filenames with invalid UTF-8 were handled. On the Ubuntu side, 26.04 LTS is the sensible base for a long-lived server. Ubuntu 26.10 is an interim release supported until July 2027, according to Ubuntu’s list of releases. If you already run a SIEM, our guide to Wazuh SIEM setup with Docker covers the fleet-wide version of the same idea. AIDE stays the lightweight pick for a single host.

By the end you will have a hashed baseline of the files that matter, custom rules with the noise filtered out, a tested detection, a daily systemd timer, alerts to syslog, mail, or a chat webhook, an off-box copy of the baseline, and a bootstrap script that repeats the whole setup on the next server.

Why File Integrity Monitoring Still Matters on Ubuntu Servers

Most intrusion write-ups end the same way. The attacker got in, changed something that should never change, and stayed for weeks because nothing compared today’s filesystem to yesterday’s. File integrity monitoring closes that gap. It stores a cryptographic fingerprint of each watched file, then flags every file that was added, removed, or altered since the last scan.

Marco Maiorano put the mechanism plainly in an older Linux Gazette walkthrough: “File integrity checkers can help us by keeping checksums or hashes, and various attributes like size, owner, permissions, etc. of files in a database to later, and regularly, compare this information checking for changes.” That is still exactly what AIDE does.

The tool has a long track record. Rami Lehti and Pablo Virolainen wrote the original AIDE in 1999. Richard van den Berg maintained it from 2003 to 2010, and Hannes von Haugwitz took over in October 2010. It ships under the GPL-2.0 license, so there is nothing to buy and no license key to track.

Auditors like FIM because many compliance standards ask for change detection on critical files. Passing an audit is a side benefit, though. The real payoff is the 3 a.m. alert that says /usr/sbin/sshd changed while nobody ran an upgrade.

FIM prevents nothing. It detects, after the fact, and only for the paths and attributes you told it to watch. Treat it as one layer next to patching, key-only SSH, a firewall, and audit logging. Pair it with auditd if you also want to know which user touched the file, because AIDE tells you what changed but not who changed it.

Prerequisites and Versions

You need a fresh or known-clean Ubuntu Server, a user with sudo, and about an hour. Known-clean matters more than anything else on this list. AIDE trusts the system it scans the first time, so a baseline built on an already compromised host just memorizes the compromise.

Component Version to use Why
Ubuntu Server 26.04 LTS Current long-term support release and the right base for a host that stays up for years
Ubuntu Server (alternative) 26.10 Interim release from October 15, 2026, supported until July 2027
AIDE 0.19.5 or newer Current stable release on the project site, with fixes for two detection-bypass advisories
Shell and tools bash, systemd, curl All present on a default Ubuntu Server install
Privileges sudo Root is needed to read every watched path
Optional A mail command or a chat webhook URL Delivers the alerts in Step 11

One caveat on the AIDE row. Ubuntu’s archive version can trail the upstream release, and the search results behind this guide do not show which build 26.04 carries. Check yours in Step 2 with apt-cache policy aide. If the archive ships 0.19.4 or older, read the Ubuntu security notices for the aide package and consider the source-build option described in Step 2.

You also need somewhere to keep a second copy of the baseline: another server, an object-storage bucket with write-once settings, or a USB stick that lives in a drawer. If you are still choosing a distribution for hardened servers, our Ubuntu vs Fedora comparison covers support windows and packaging. The concepts below carry over to Fedora and RHEL-family systems, but file paths and the init command differ there.

How AIDE Works: Baseline, Rules, and Checks

AIDE has three moving parts. A configuration file says which paths to watch and which attributes to record for each. The init run walks those paths and writes a database, which is your baseline. Every later check walks the same paths again, compares the result against the database, and prints a report of anything that differs.

The attribute names are the part people trip over, so memorize the short list in the table below. The AIDE manual documents every one of them, and the letters combine with plus signs into rule groups such as p+i+n+u+g+s+sha256.

Attribute What it records
p Permissions
ftype File type (regular file, directory, symlink)
i Inode number
n Number of links
u and g Owner and group
s Size
m and c Modification time and inode change time
S Check for growing size
sha256 and sha512 Cryptographic content hashes
acl POSIX access control lists
xattrs Extended attributes
selinux SELinux context, where the system uses it

Path lines in the config follow a simple grammar. A line like /etc MyRule means “watch everything under /etc using MyRule”. A line starting with ! excludes a path, and a line starting with = matches one directory without recursing. The paths are regular expressions anchored at the start, so a dot in a filename needs a backslash if you want a literal match. AIDE applies the first rule that matches a file, which makes the order of your rules matter.

Linux.com once described AIDE as an open source IDS that you can set up in a weekend. With a working baseline and the scripts below, you will beat that estimate by a wide margin. The slow part is not the install. It is tuning the rules so the daily report stays quiet enough that a human still reads it.

Steps 1 to 3: Prepare the Host, Install AIDE, Read the Defaults

Step 1: Patch the host and take a snapshot

Bring the system fully up to date before you build the baseline. Every package you update afterward will show up as a change, so patching first keeps the first report short. Reboot if the kernel or libc moved.

lsb_release -d
sudo apt update
sudo apt full-upgrade -y
[ -f /var/run/reboot-required ] && echo "Reboot needed" || echo "No reboot needed"

If the server is a VM, take a hypervisor snapshot now. If it is bare metal, at least confirm that you can log in with an SSH key and that sudo works, because the later steps touch system paths. Desktop users on Linux Mint can follow the same steps, since Mint builds on Ubuntu’s packages. Our Linux Mint vs Ubuntu comparison explains how closely the two track each other.

Step 2: Install AIDE and check the version

Two packages matter. aide holds the scanner, and aide-common holds the Debian and Ubuntu glue: the aideinit helper, the update-aide.conf generator, and the stock config. On a headless server, skip recommended packages so apt does not drag in a full mail server and stall on a debconf prompt.

sudo DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends aide aide-common
aide --version | head -n 3
apt-cache policy aide

The output names whatever your archive ships. The 0.xx.x below is a stand-in for that number.

Aide 0.xx.x

aide:
  Installed: 0.xx.x-0ubuntuX
  Candidate: 0.xx.x-0ubuntuX

Compare that number with 0.19.5. If yours is lower, you have two options. You can wait for a patched package and mitigate in the meantime by keeping the baseline off-box and cross-checking with dpkg --verify in Step 13. Or you can build the current release from the signed tarball on the project’s GitHub releases page. A source build follows the usual ./configure, make, sudo make install routine, and it installs into /usr/local by default. Make sure every script you write afterward points at that binary and not the packaged one.

Step 3: Read the stock configuration

Ubuntu does not run AIDE straight from /etc/aide/aide.conf. The helper update-aide.conf merges that file with every snippet in /etc/aide/aide.conf.d/ and writes the result to /var/lib/aide/aide.conf.autogenerated. Every command in this guide uses the generated file. Look at both, plus the database settings.

grep -E '^(database|gzip_dbout|report_url)' /etc/aide/aide.conf
ls /etc/aide/aide.conf.d | head -n 20
grep -n 'x_include' /etc/aide/aide.conf
database_in=file:/var/lib/aide/aide.db
database_out=file:/var/lib/aide/aide.db.new
database_new=file:/var/lib/aide/aide.db.new
gzip_dbout=yes
report_url=stdout

Your file names and values may differ slightly between Ubuntu releases, so trust what your own grep prints. Two details deserve attention. The x_include line carries a pattern that limits snippet names to letters, digits, underscores, and hyphens. A snippet called local.rules would be silently skipped because of the dot. And the stock snippets already watch much of the filesystem, which is why Step 5 gives your own file a low number so its rules win under the first-match behavior.

Steps 4 and 5: Write Rules That Match Your Server

Step 4: Decide what to watch and what to skip

Good FIM rules come from asking where an attacker needs to write to stay put. The answer is a short list: boot files, system binaries and libraries, configuration, scheduled-job directories, service definitions, and SSH keys. Everything that changes legitimately all day, such as logs, caches, package state, and container layers, belongs on the exclusion list. A report full of expected churn trains people to stop reading it, and an unread report is worse than none.

  • Watch strictly: /boot, /etc, /usr/local/bin, /usr/local/sbin, /root/.ssh, each user’s .ssh directory, and your own application directories.
  • Watch with the stock rules: /bin, /sbin, /usr/bin, /usr/sbin, and /lib*, which the Ubuntu snippets already cover.
  • Exclude: /var/log, /var/cache, /var/tmp, /tmp, /run, /proc, /sys, /dev, /var/lib/apt, /var/lib/aide, /snap, /var/lib/snapd, and container storage under /var/lib/docker and /var/lib/containerd.

Before you write the rules, create three small lab files under /etc. Step 9 will tamper with them so you can watch AIDE catch the edits without touching anything real.

sudo install -d -m 0755 /etc/fim-lab
echo "alpha"   | sudo tee /etc/fim-lab/alpha.conf   > /dev/null
echo "bravo"   | sudo tee /etc/fim-lab/bravo.conf   > /dev/null
echo "charlie" | sudo tee /etc/fim-lab/charlie.conf > /dev/null
ls -l /etc/fim-lab

Step 5: Create the local rules snippet

Make a project folder first. Several later steps put files there, and the bootstrap script at the end installs from it.

mkdir -p ~/aide-lab
cat > ~/aide-lab/05_local_rules <<'EOF'
# Local AIDE rules. Installed as /etc/aide/aide.conf.d/05_local_rules
LabStrict = p+i+n+u+g+s+m+c+acl+xattrs+sha256+sha512
LabPerms  = p+u+g+acl+xattrs

# Strict watch on the places an attacker needs to persist
/boot                  LabStrict
/etc                   LabStrict
/usr/local/bin         LabStrict
/usr/local/sbin        LabStrict
/root/.ssh             LabStrict
/home/[^/]+/.ssh      LabStrict

# Known noise inside /etc
!/etc/mtab$
!/etc/.pwd.lock$
!/etc/adjtime$
!/etc/ld.so.cache$
!/etc/resolv.conf$

# Volatile or self-referential paths
!/var/lib/aide
!/var/lib/apt
!/var/log
!/var/cache
!/var/tmp
!/tmp
!/run
!/proc
!/sys
!/dev
!/snap
!/var/lib/snapd
!/var/lib/docker
!/var/lib/containerd
EOF
sudo install -m 0644 ~/aide-lab/05_local_rules /etc/aide/aide.conf.d/05_local_rules
sudo update-aide.conf
sudo aide --config-check --config /var/lib/aide/aide.conf.autogenerated; echo "config-check exit=$?"

A clean config prints nothing and ends with config-check exit=0. Any typo produces an error that names the line number in the generated file. The generated file is the one to open when you debug, because it is the text AIDE actually parses.

config-check exit=0

The two custom groups do different jobs. LabStrict records everything useful, including both hash algorithms, so a change that preserves size and timestamps still trips the alarm. LabPerms skips content hashing and suits directories where files change often but ownership and modes should not. Use it for upload folders and similar spots when you extend the rules later.

Steps 6 and 7: Build the Baseline and Lock It Down

Step 6: Initialize the database

This is the moment of trust. Make sure nobody else is logged in, nothing is mid-upgrade, and you have not just installed software you plan to remove. The run reads and hashes every watched file, so expect a few minutes on a fresh server and longer on hosts with big application trees. Run it once, outside peak hours.

sudo aideinit -y -f
ls -l /var/lib/aide/

The -y flag skips the confirmation prompt and -f overwrites any earlier database. When it finishes, the new database is written and copied into place as the active baseline. Entry counts and file names vary by host.

Running aide --init...
Start timestamp: 2026-11-05 09:12:44 +0000 (AIDE 0.xx.x)
AIDE successfully initialized database.
New AIDE database written to /var/lib/aide/aide.db.new

Number of entries:      28411

-rw------- 1 root root 11204315 Nov  5 09:17 aide.db
-rw------- 1 root root 11204315 Nov  5 09:17 aide.db.new
-rw-r--r-- 1 root root     9876 Nov  5 09:12 aide.conf.autogenerated

If aide.db is missing and only aide.db.new exists, copy it over by hand with sudo cp -p /var/lib/aide/aide.db.new /var/lib/aide/aide.db. Use the file name that database_in printed in Step 3.

Step 7: Fingerprint the baseline and move a copy off the box

An integrity database stored only on the machine it protects is a weak control. An intruder with root can edit the database to match their changes, and every later check will pass. Defend against that in two layers. First, record hashes of the database, the generated config, and the AIDE binary itself. Second, copy those files somewhere the monitored host cannot write to.

sudo install -d -m 0700 /root/aide-baseline
sudo cp -p /var/lib/aide/aide.db /var/lib/aide/aide.conf.autogenerated /root/aide-baseline/
sudo sh -c 'sha256sum /var/lib/aide/aide.db /var/lib/aide/aide.conf.autogenerated "$(command -v aide)" > /root/aide-baseline/SHA256SUMS'
sudo cat /root/aide-baseline/SHA256SUMS
3f1c...e9a2  /var/lib/aide/aide.db
a07b...51cd  /var/lib/aide/aide.conf.autogenerated
c94e...7b10  /usr/bin/aide

Now ship the folder away. The example below pushes it to a separate backup host over SSH. Swap in object storage with retention locks or a removable drive if that suits you better. The point is that a stolen root account on this server cannot rewrite the copy.

sudo tar -C /root -czf /tmp/aide-baseline-$(hostname)-$(date +%F).tgz aide-baseline
scp /tmp/aide-baseline-*.tgz backup@backup.example.internal:/srv/aide-baselines/
sudo rm /tmp/aide-baseline-*.tgz

For an extra layer, set the immutable flag on the active database with sudo chattr +i /var/lib/aide/aide.db. An attacker has to clear the flag first, which is one more noisy step. Remember to run sudo chattr -i on the file before any legitimate baseline update in Step 13.

Steps 8 and 9: Run a Check and Trigger a Real Detection

Step 8: Run the first check

With nothing changed, the check should come back clean. A handful of differences right after init is normal on a busy host, usually from package-manager state or a file written between the scan and the check.

sudo aide --check --config /var/lib/aide/aide.conf.autogenerated; echo "aide exit=$?"
Start timestamp: 2026-11-05 09:31:02 +0000 (AIDE 0.xx.x)
AIDE found NO differences between database and filesystem. Looks okay!!

aide exit=0

The exit code is how automation reads the result. AIDE builds it as a bit mask, so differences of several kinds add together. A run that finds one new file, one removed file, and one changed file exits with 7.

Exit code Meaning
0 No differences
1 New files found
2 Removed files found
4 Changed files found
1 to 7 Any combination of the three above, added together
14 Error writing output
15 Invalid argument
16 Unimplemented function
17 Invalid configuration line
18 I/O error
19 Version mismatch between database and binary

Run man aide on your system to confirm the table against your installed version. Anything from 14 up is a tool failure rather than a finding, and your alerting should treat it as a separate, louder category.

Step 9: Tamper with the lab files on purpose

A monitor you have never seen fire is a monitor you cannot trust. Make four deliberate changes to the lab files from Step 4: edit the content of one, loosen the permissions on another, delete the third, and add a brand-new file.

echo "tampered" | sudo tee -a /etc/fim-lab/alpha.conf > /dev/null
sudo chmod 666 /etc/fim-lab/bravo.conf
sudo rm /etc/fim-lab/charlie.conf
echo "delta" | sudo tee /etc/fim-lab/delta.conf > /dev/null

sudo aide --check --config /var/lib/aide/aide.conf.autogenerated; echo "aide exit=$?"

The report opens with a summary, lists the three categories, and then prints per-file details. The flag columns in the “Changed entries” section differ between AIDE versions, so they are shortened here. Read the detailed block, which is the same in every release.

AIDE found differences between database and filesystem!!

Summary:
  Total number of entries:	28411
  Added entries:		1
  Removed entries:		1
  Changed entries:		2

---------------------------------------------------
Added entries:
---------------------------------------------------
f+++++++++++++++++: /etc/fim-lab/delta.conf

---------------------------------------------------
Removed entries:
---------------------------------------------------
f----------------: /etc/fim-lab/charlie.conf

---------------------------------------------------
Changed entries:
---------------------------------------------------
f ... : /etc/fim-lab/alpha.conf
f ... : /etc/fim-lab/bravo.conf

---------------------------------------------------
Detailed information about changes:
---------------------------------------------------
File: /etc/fim-lab/alpha.conf
 Size      : 6                      | 15
 SHA256    : (old hash)             | (new hash)

File: /etc/fim-lab/bravo.conf
 Perm      : -rw-r--r--             | -rw-rw-rw-

aide exit=7

Exit code 7 is the sum 1 + 2 + 4, so all three change types fired. The content edit shows new size and hash values, and the permission change shows the old and new mode strings side by side. That pairing of old and new values is what makes an AIDE report actionable at 3 a.m. Reset the lab before you move on.

echo "alpha"   | sudo tee /etc/fim-lab/alpha.conf   > /dev/null
sudo chmod 644 /etc/fim-lab/bravo.conf
echo "charlie" | sudo tee /etc/fim-lab/charlie.conf > /dev/null
sudo rm /etc/fim-lab/delta.conf
sudo chmod 644 /etc/fim-lab/*.conf
sudo aide --check --config /var/lib/aide/aide.conf.autogenerated | head -n 12

The re-created files get new inode numbers and timestamps, and LabStrict records both. Expect the lab files to show as changed in this check even though their content matches. That is correct behavior and a useful reminder of how strict the rule is. Step 13 folds the lab files back into a fresh baseline. If you want more cybersecurity walkthroughs of this kind, the cybersecurity guides archive collects them.

Steps 10 and 11: Schedule Daily Checks and Send Alerts

Step 10: Schedule the check with a systemd timer

Ubuntu’s aide-common package can ship its own daily timer, dailyaidecheck.timer. Look for it first, because a timer you did not know about will double your reports.

systemctl list-timers --all | grep -i aide
ls /etc/cron.daily | grep -i aide
systemctl cat dailyaidecheck.timer 2>/dev/null | head -n 20

The packaged job reads its settings from /etc/default/aide, where you can set a mail recipient. That works if the server has a configured mail transport and you are happy with plain-text reports. This guide uses a small custom timer instead, because it lets the same script write to syslog, send mail, and call a webhook, and it returns a non-zero exit status when AIDE finds something. That status shows up in systemctl --failed and in any monitoring agent that watches unit state.

Create the two unit files in the project folder. The service is a one-shot job that runs at low CPU and disk priority so the nightly scan does not compete with real work.

cat > ~/aide-lab/aide-check.service <<'EOF'
[Unit]
Description=AIDE integrity check with alerting
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/aide-check-report
Nice=10
IOSchedulingClass=idle
EOF

cat > ~/aide-lab/aide-check.timer <<'EOF'
[Unit]
Description=Daily AIDE integrity check

[Timer]
OnCalendar=*-*-* 03:30:00
RandomizedDelaySec=15m
Persistent=true

[Install]
WantedBy=timers.target
EOF

Persistent=true makes the timer catch up after a reboot if the server was off at 03:30, and the 15-minute random delay stops a fleet of servers from hashing their disks in the same minute. Do not enable the timer yet. It needs the report script from the next step.

Step 11: Write the report-and-alert script

The script runs the check, saves the full report to a timestamped file, and turns the exit code into one of three outcomes. A clean run logs a single info line. Differences log a warning and fire the alert channels. A tool failure logs an error and fires them with a different subject, so you never confuse “AIDE broke” with “AIDE found something”.

cat > ~/aide-lab/aide-check-report <<'EOF'
#!/usr/bin/env bash
# Installed as /usr/local/sbin/aide-check-report
set -u

CONF=/var/lib/aide/aide.conf.autogenerated
OUT_DIR=/var/log/aide
ENV_FILE=/etc/aide-alert.env
AIDE_BIN=$(command -v aide || echo /usr/bin/aide)
HOST=$(hostname -f 2>/dev/null || hostname)
STAMP=$(date -u +%Y%m%dT%H%M%SZ)
REPORT="$OUT_DIR/check-$STAMP.log"

ALERT_MAIL=""
ALERT_WEBHOOK=""
[ -r "$ENV_FILE" ] && . "$ENV_FILE"

install -d -m 0750 "$OUT_DIR"

"$AIDE_BIN" --check --config "$CONF" >"$REPORT" 2>&1
RC=$?

SUMMARY=$(grep -E '(Total number of entries|Added entries|Removed entries|Changed entries):' "$REPORT" 
  | sed 's/[[:space:]]+/ /g' | paste -sd '|' -)

if [ "$RC" -eq 0 ]; then
  logger -t aide-check -p authpriv.info "clean on $HOST"
  exit 0
fi

if [ "$RC" -ge 14 ]; then
  LEVEL=authpriv.err
  SUBJECT="AIDE ERROR (exit $RC) on $HOST"
  EXITCODE=20
else
  LEVEL=authpriv.warning
  SUBJECT="AIDE differences on $HOST"
  EXITCODE=10
fi

logger -t aide-check -p "$LEVEL" "$SUBJECT $SUMMARY report=$REPORT"

if [ -n "$ALERT_MAIL" ] && command -v mail >/dev/null 2>&1; then
  head -n 300 "$REPORT" | mail -s "$SUBJECT" "$ALERT_MAIL"
fi

if [ -n "$ALERT_WEBHOOK" ]; then
  curl -fsS -m 15 -H 'Content-Type: application/json' 
    -d "{"text":"$SUBJECT $SUMMARY"}" "$ALERT_WEBHOOK" >/dev/null 
    || logger -t aide-check -p authpriv.err "webhook delivery failed"
fi

find "$OUT_DIR" -name 'check-*.log' -mtime +90 -delete
exit "$EXITCODE"
EOF

cat > ~/aide-lab/aide-alert.env <<'EOF'
# Fill in one or both. Leave blank to log to syslog only.
ALERT_MAIL=""
ALERT_WEBHOOK=""
EOF

The webhook body uses the {"text": "..."} shape that Slack-compatible and Mattermost-style incoming webhooks accept. Other services want different JSON, so adjust that one line. After the next scheduled run, find the one-line verdicts in the journal.

journalctl -t aide-check --since today --no-pager
Nov 06 03:41:09 web01 aide-check[2214]: AIDE differences on web01 Total number of entries: 28411|Added entries: 1|Removed entries: 0|Changed entries: 2 report=/var/log/aide/check-20261106T034102Z.log

Steps 12 and 13: Verify the Baseline and Update It After Patching

Step 12: Verify the baseline before you trust a report

When an alert fires, the first question is whether to believe the checker. Answer it by comparing the live database, config, and binary against the hashes you saved in Step 7. Better still, pull the off-box copy back and compare against that, since an intruder could have rewritten the local SHA256SUMS file too.

sudo sha256sum -c /root/aide-baseline/SHA256SUMS
/var/lib/aide/aide.db: OK
/var/lib/aide/aide.conf.autogenerated: OK
/usr/bin/aide: OK

A FAILED line on /usr/bin/aide after a package upgrade is expected, because the upgrade replaced the binary. A FAILED line on aide.db with no recent update is not. Treat it as an incident until proven otherwise.

Step 13: Update the baseline after legitimate changes

Patches, new services, and config changes all create differences you want AIDE to accept. The safe sequence is review first, accept second. Never re-run aideinit -f to make an alert go away, because that rebuilds the baseline from whatever the disk looks like right now, intruder changes included.

CONF=/var/lib/aide/aide.conf.autogenerated

# 1. Allow the database to be rewritten if you set the immutable flag
sudo chattr -i /var/lib/aide/aide.db 2>/dev/null

# 2. Review every difference and save the evidence
sudo aide --check --config "$CONF" | tee ~/aide-review-$(date +%F).log

# 3. Independent cross-check: which packaged files differ from their package checksums?
sudo dpkg --verify

# 4. Accept: write a new database that includes the current state
sudo aide --update --config "$CONF"
sudo cp -p /var/lib/aide/aide.db.new /var/lib/aide/aide.db

# 5. Re-fingerprint and re-copy off the box (repeat Step 7)
sudo sh -c "sha256sum /var/lib/aide/aide.db $CONF $(command -v aide) > /root/aide-baseline/SHA256SUMS"

The dpkg --verify call is the cross-check that makes the review trustworthy. It compares installed files with the checksums stored in the package database. After a normal upgrade, AIDE’s changed list under /usr should line up with packages you actually updated, and dpkg --verify should stay quiet about them. Configuration files marked with a c in its output are expected to differ when you edited them on purpose. Any changed binary that neither matches an upgrade nor shows up in the package checksums deserves a closer look.

Time the update around your patch window. Run a check immediately before upgrading so the old baseline is proven clean, upgrade, then run the review-and-accept sequence above. A release upgrade needs extra patience. Canonical described Ubuntu 26.10 as completing the rollout of the Rust-based uutils coreutils, so moving a server onto that release should rewrite many core binaries at once. Expect a very long change list and rebuild the baseline deliberately after you review it.

Full Working Project: One Bootstrap Script for Every New Server

Steps 5, 10, and 11 already filled ~/aide-lab with four files: the rules snippet, the service and timer units, the report script, and the alert settings. Two more files finish the project. The first is a self-test that proves your AIDE binary detects added, removed, and changed files using a throwaway config, so it never touches the production baseline. The second is the bootstrap script that installs everything in order.

cat > ~/aide-lab/selftest.sh <<'EOF'
#!/usr/bin/env bash
# Proves the installed AIDE detects add, remove, content and permission changes.
set -u
AIDE_BIN=$(command -v aide || echo /usr/bin/aide)
T=$(mktemp -d /tmp/aide-selftest.XXXXXX)
trap 'rm -rf "$T"' EXIT

mkdir -p "$T/data"
echo one   >"$T/data/a.txt"
echo two   >"$T/data/b.txt"
echo three >"$T/data/c.txt"

cat >"$T/aide.conf" <<CFG
database_in=file:$T/db.in
database_out=file:$T/db.out
gzip_dbout=no
report_url=stdout
Selftest = p+i+n+u+g+s+m+c+sha256
$T/data Selftest
CFG

if ! "$AIDE_BIN" --init --config "$T/aide.conf" >/dev/null 2>&1; then
  echo "SELFTEST FAIL: could not initialize a test database"
  exit 1
fi
mv "$T/db.out" "$T/db.in"

echo changed >>"$T/data/a.txt"
chmod 600 "$T/data/b.txt"
rm "$T/data/c.txt"
echo four >"$T/data/d.txt"

"$AIDE_BIN" --check --config "$T/aide.conf" >"$T/report.txt" 2>&1
RC=$?

if [ "$RC" -eq 7 ]; then
  echo "SELFTEST PASS: add, remove and change detected (exit 7)"
  exit 0
fi
echo "SELFTEST FAIL: expected exit 7, got $RC"
cat "$T/report.txt"
exit 1
EOF

cat > ~/aide-lab/bootstrap.sh <<'EOF'
#!/usr/bin/env bash
# Run as root from inside the aide-lab folder: sudo ./bootstrap.sh
set -euo pipefail

LAB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONF=/var/lib/aide/aide.conf.autogenerated
SAFE=/root/aide-baseline

if [ "$(id -u)" -ne 0 ]; then
  echo "Run as root: sudo $0" >&2
  exit 1
fi

echo "[1/7] Installing packages"
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y --no-install-recommends aide aide-common curl

echo "[2/7] Installing local rules"
install -m 0644 "$LAB_DIR/05_local_rules" /etc/aide/aide.conf.d/05_local_rules
update-aide.conf
aide --config-check --config "$CONF"

echo "[3/7] Running the self-test"
bash "$LAB_DIR/selftest.sh"

echo "[4/7] Building the baseline"
if [ -s /var/lib/aide/aide.db ] && [ "${FORCE:-0}" != "1" ]; then
  echo "     Baseline exists. Set FORCE=1 to rebuild it (only on a known-clean host)."
else
  aideinit -y -f
fi

echo "[5/7] Fingerprinting the baseline"
install -d -m 0700 "$SAFE"
cp -p /var/lib/aide/aide.db "$CONF" "$SAFE/"
sha256sum /var/lib/aide/aide.db "$CONF" "$(command -v aide)" > "$SAFE/SHA256SUMS"

echo "[6/7] Installing the check script and timer"
install -m 0750 "$LAB_DIR/aide-check-report" /usr/local/sbin/aide-check-report
[ -f /etc/aide-alert.env ] || install -m 0600 "$LAB_DIR/aide-alert.env" /etc/aide-alert.env
install -m 0644 "$LAB_DIR/aide-check.service" /etc/systemd/system/aide-check.service
install -m 0644 "$LAB_DIR/aide-check.timer" /etc/systemd/system/aide-check.timer
systemctl daemon-reload
systemctl disable --now dailyaidecheck.timer 2>/dev/null || true
systemctl enable --now aide-check.timer
if ls /etc/cron.daily 2>/dev/null | grep -qi aide; then
  echo "     WARNING: a cron.daily AIDE job also exists. Disable one of them."
fi

echo "[7/7] Done"
systemctl list-timers aide-check.timer --no-pager
echo "Copy $SAFE off this host now (see Step 7)."
EOF

chmod +x ~/aide-lab/*.sh ~/aide-lab/aide-check-report
bash -n ~/aide-lab/selftest.sh && bash -n ~/aide-lab/bootstrap.sh && echo "syntax OK"

Run it from a fresh server and watch the seven stages scroll by. Each stage prints one line, so a failure is easy to place. The self-test runs before the real baseline is built, which means a broken or badly packaged AIDE binary stops the script early instead of producing a baseline you cannot trust.

cd ~/aide-lab
sudo ./bootstrap.sh
[1/7] Installing packages
[2/7] Installing local rules
[3/7] Running the self-test
SELFTEST PASS: add, remove and change detected (exit 7)
[4/7] Building the baseline
[5/7] Fingerprinting the baseline
[6/7] Installing the check script and timer
[7/7] Done
NEXT                         LEFT        LAST PASSED UNIT             ACTIVATES
Fri 2026-11-06 03:38:12 UTC  18h left    n/a  n/a    aide-check.timer aide-check.service
Copy /root/aide-baseline off this host now (see Step 7).

Finish with a manual run of the service, which exercises the full alert path without waiting for 03:30. Add a webhook URL or mail address to /etc/aide-alert.env first if you want to test delivery. Then make one deliberate change under /etc, run the service, and confirm the alert arrives.

echo "# alert path test" | sudo tee -a /etc/fim-lab/alpha.conf > /dev/null
sudo systemctl start aide-check.service
systemctl status aide-check.service --no-pager | head -n 8
journalctl -t aide-check -n 3 --no-pager

The service shows as failed with status 10, which is the intended signal for “differences found”. Revert the edit, or accept it by following Step 13, so tomorrow’s report starts clean.

Common Pitfalls That Quietly Break File Integrity Monitoring

  • Baselining a dirty host. AIDE records what exists, not what is good. If you init after a suspected break-in or a messy install, you bake the problem into the reference. Rebuild the machine first.
  • Skipping update-aide.conf. Edits to snippets in /etc/aide/aide.conf.d/ do nothing until the generated config is rebuilt. Run it after every change, then run --config-check.
  • Dots in snippet names. The include pattern accepts letters, digits, underscores, and hyphens. local.rules vanishes without an error. Use 05_local_rules.
  • Watching volatile paths. Logs, caches, and container layers produce hundreds of daily changes. Once people learn the report is always noisy, they stop opening it, and the one real alert gets lost.
  • Keeping the only database copy on the monitored host. Root on the box means control over the database. Store a fingerprinted copy elsewhere, as in Step 7.
  • Rebuilding the baseline to silence alerts. Running aideinit -f after every report erases the evidence. Review, cross-check with dpkg --verify, then use --update.
  • Never testing the alert channel. A mail command with no working transport drops messages without a visible error. Send a test change through the full path, as in the project section.
  • Forgetting package upgrades are changes. Patch night produces a long report by design. Check before the upgrade, review after, and accept deliberately.

Troubleshooting AIDE on Ubuntu

Most failures fall into a few buckets: a missing database, a config that does not parse, or a check that is correct but noisy. Match your symptom in the table, then apply the fix.

Symptom Likely cause Fix
aideinit: command not found aide-common missing, or /usr/sbin not on your path Install aide-common and call sudo aideinit
“Couldn’t open file … for reading” during a check Baseline never copied into place, or database_in points elsewhere Re-read Step 3, then copy aide.db.new to the database_in name
Exit 17, “invalid configuration line” Typo or unescaped character in a rule Run --config-check against the generated file and fix the reported line
Your rules have no effect Snippet name has a dot, update-aide.conf was not rerun, or an earlier stock rule matched first Rename the file, regenerate, and keep your snippet’s number low
Hundreds of changes after apt upgrade Expected: upgraded packages replace files Follow Step 13 and cross-check with dpkg --verify
Check runs for a long time or hammers the disk Watching large data trees or container storage Exclude them, keep the Nice and idle I/O settings, schedule off-peak
No alert email arrives No mail transport on the host Test echo test | mail -s test you@example.com, or switch to the webhook or journal
Exit 14 or 18 on init or update Full disk, read-only mount, or immutable flag on the database Check df -h /var/lib/aide and lsattr /var/lib/aide, then clear the flag with chattr -i
Exit 19, version mismatch Database written by a different AIDE version than the one checking Review changes, then rebuild the baseline with the current binary
Timer never fires Timer not enabled, or a typo in OnCalendar Run systemctl list-timers and journalctl -u aide-check.service, then systemd-analyze calendar "*-*-* 03:30:00"
Strange filenames in reports, or suspected missed changes Running a build affected by the invalid-UTF-8 filename advisory Upgrade to 0.19.5 or newer
Duplicate reports every night Packaged dailyaidecheck timer or a cron job still active Disable the one you do not use

When none of those fit, run the check by hand with verbose output using sudo aide --check --config /var/lib/aide/aide.conf.autogenerated -V5 and read what the scanner reports about each directory. If a path you expected never appears, a rule or exclusion is hiding it. If you use Arch on some machines, the packaging differs enough that our Arch Linux vs Ubuntu comparison is worth a skim before you copy these paths over.

Advanced Tips for Production File Integrity Monitoring

Compare two databases. After aide --update writes the new database, aide --compare diffs the old and new files. It gives you a second, cleaner view of exactly what you are about to accept, without re-scanning the disk.

Sign the baseline. Create a detached GPG signature with gpg --detach-sign --armor aide.db on a workstation, not on the server. Store the signature next to the off-box copy. Verifying it before a restore proves nobody swapped the file in storage.

Keep generations. Archive each accepted baseline with a date in the file name. When an investigation asks “when did this binary first change”, old databases answer it. They are small compared with the value of the timeline.

Forward the alert tag to central logging. The script writes to syslog under the aide-check tag. A log shipper or SIEM agent can pick that tag up and page you from one place. Wazuh agents, for example, can ingest syslog sources, which lets a small fleet keep AIDE for host-level baselines and still alert from a single console.

Add application paths per role. A web server gets /var/www under LabStrict with the upload directories excluded or moved to LabPerms. A database host gets its configuration directory but not its data directory. Write each role as its own numbered snippet so the rules stay readable.

Use the Ubuntu hardening tooling if you have it. Canonical lists hardening with CIS and DISA-STIG profiles among the Ubuntu Pro features, and Ubuntu Pro is free for up to five machines. CIS profiles check for AIDE, so a hardening audit will flag servers that lack it. Treat that as a safety net rather than a replacement for the tuned rules above.

Check from trusted media for high-value hosts. A kernel-level rootkit can lie to any tool running on the compromised system, AIDE included. For servers that justify the effort, boot a trusted live image, mount the disk read-only, and run a known-good AIDE binary against it with the baseline from your off-box copy. Adjust the rule paths for the mount point first.

Watch desktops too. Developer laptops hold SSH keys, cloud credentials, and signing keys. A workstation that mostly runs games through a streaming client, like the one in our GeForce NOW Linux setup guide, still stores a browser profile and SSH keys worth protecting. A lean AIDE config limited to /etc, ~/.ssh, and shell startup files costs almost nothing to run.

AIDE vs Wazuh FIM, Tripwire, Samhain, and auditd

AIDE is not the only way to watch files, and it is not always the right one. The table sorts the common options by what each does best. Broader planning usually starts with a SIEM or endpoint comparison, and this table is the file-level slice of that decision.

Tool Model Best for Trade-off
AIDE Local hash database, scheduled scans Single hosts and small fleets that want a free, auditable baseline (GPL-2.0) No central console, you build alerting yourself
Wazuh FIM Agent with central manager Fleets that already need a SIEM, with centralized management and alerting Heavier to run and operate
Tripwire Commercial, enterprise-oriented platform Organizations that want vendor support and reporting License cost and vendor lock-in
Samhain Integrity checking plus broader host monitoring Teams that want one agent for several host checks More moving parts than AIDE
auditd Kernel audit events Learning who touched a file and when, in real time No baseline hashes, so it cannot prove content is unchanged

The practical answer for most small teams is to run AIDE and auditd together. AIDE gives you the proof that a file differs from a known-good copy, and the audit log tells you which account and process made the edit. Add a SIEM later if the fleet grows.

Frequently Asked Questions

What is file integrity monitoring, and does AIDE do it?

File integrity monitoring compares the current state of files with a trusted baseline and reports additions, deletions, and modifications. AIDE does exactly that by storing hashes and attributes in a database, then checking the filesystem against it on a schedule.

Is AIDE free to use?

Yes. The project is open source under the GPL-2.0 license. Your costs are the server time to run scans and the effort to tune rules and alerts.

How often should I run an AIDE check?

Daily is the common default and is what this guide sets up. Internet-facing or high-value servers can run it more often, provided the scan stays light enough not to disturb the workload. Narrow rule sets scan faster, so a short list of critical paths can run hourly while a full scan runs nightly.

Do I need to rebuild the AIDE database after every update?

You need to update it, not rebuild it. Review the differences, cross-check them with dpkg --verify, then run aide --update and replace the active database, as in Step 13. Rebuilding from scratch with aideinit -f skips the review, which defeats the purpose.

Can an attacker just edit the AIDE database?

An attacker with root can, which is why Step 7 keeps a fingerprinted copy off the host and Step 12 verifies against it. Immutable flags and signed copies add friction, but the off-box copy is the control that actually holds.

Should I choose AIDE or Wazuh for file integrity monitoring?

Pick AIDE when you manage a handful of servers and want a simple, scriptable tool with no extra infrastructure. Pick Wazuh when you already need centralized alerting, many agents, and other detections beyond file changes. The two also work together, with Wazuh collecting the syslog alerts that AIDE writes.

Is AIDE the same thing as the Aide AI customer-support product?

No. The Advanced Intrusion Detection Environment is an open-source host security tool. Search results for “Aide” also surface an unrelated AI helpdesk product with its own plans and pricing, and none of that applies here.

Will these steps work on Ubuntu 26.10 as well as 26.04 LTS?

The commands use standard Ubuntu tooling, so they should carry over. Confirm the packaged AIDE version with apt-cache policy aide on your release first. For a production server, the LTS release is the safer base because 26.10 is an interim release supported only until July 2027.

Related Coverage

Source: Tech Insider