On this page
- What does a file integrity checker do?
- AIDE or Tripwire: which should I pick?
- How do I install AIDE on Ubuntu and Debian?
- How do I install AIDE on Rocky Linux and AlmaLinux?
- How do I run checks automatically?
- How do I update the baseline after planned changes?
- How do I reduce noise in the reports?
- How do I set up Tripwire on Ubuntu or Debian?
- What should I do when a report shows an unexpected change?
- Questions
What does a file integrity checker do?
It records a fingerprint of important files, then tells you when any of them change. For each file AIDE stores checksums plus metadata such as permissions, owner, size, inode and timestamps. A later check walks the same paths and compares. If an attacker replaces /usr/bin/ssh, adds a cron job or edits /etc/passwd, the report lists it.
Integrity monitoring does not prevent an intrusion; it shortens the time until you notice one. It works best alongside a firewall, key based SSH (see the SSH keys tutorial) and regular updates.
AIDE or Tripwire: which should I pick?
Both follow the same idea. AIDE (Advanced Intrusion Detection Environment) is packaged in the main repositories of Ubuntu, Debian, Rocky Linux and AlmaLinux, ships sensible default rules and needs no key management. Open source Tripwire signs its policy and database with site and local keys, which makes silent tampering with the baseline harder, but setup takes more steps. On Rocky and Alma, AIDE is the straightforward choice. Most readers should start with AIDE and only reach for Tripwire if signed databases matter to their audit.
How do I install AIDE on Ubuntu and Debian?
Install the package, then build the first database with the Debian wrapper script, which also copies it into place:
sudo apt update
sudo apt install aide
aide --version
sudo aideinitThe configuration lives in /etc/aide/aide.conf plus rule snippets in /etc/aide/aide.conf.d/. The first run reads every watched file and can take several minutes on a full disk. When it finishes, the trusted database sits at /var/lib/aide/aide.db. Run a manual check to confirm it works:
sudo aide --config /etc/aide/aide.conf --checkA clean system reports that all files match the database.
How do I install AIDE on Rocky Linux and AlmaLinux?
AIDE is in the BaseOS repository. Initialise the database and move the new file into the name AIDE reads during checks:
sudo dnf install aide
aide --version
sudo aide --init
sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
sudo aide --checkThe configuration file is /etc/aide.conf. Check the database_in and database_out lines there if your release uses different file names; the commands above match the defaults on version 9 systems. SELinux labels are part of the default rule set, so a relabel also appears in the report.
How do I run checks automatically?
Schedule a daily check and send the result somewhere you read. On Debian and Ubuntu the package installs a daily job; depending on release it is a cron script or a systemd timer, so look for both:
ls /etc/cron.daily/ | grep -i aide
systemctl list-timers | grep -i aideSettings for that job, such as the mail recipient, sit in /etc/default/aide. On Rocky and Alma nothing is scheduled by default, so add a root cron entry that logs the report:
sudo crontab -e
15 5 * * * /usr/sbin/aide --check > /var/log/aide/check-$(date +\%F).log 2>&1Create the folder first with sudo mkdir -p /var/log/aide. Mail delivery needs a working relay; direct port 25 is not guaranteed on a VPS, so use an authenticated relay on port 587 as described in SMTP relay for apps, or ship the log to your monitoring.
How do I update the baseline after planned changes?
Run the check, read it, and only accept the new state when every change is expected. A package upgrade legitimately changes many binaries:
# Ubuntu and Debian
sudo aide --config /etc/aide/aide.conf --update
sudo cp /var/lib/aide/aide.db.new /var/lib/aide/aide.db
# Rocky and Alma
sudo aide --update
sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gzA good habit is to run the update right after each patch session, so the daily report stays quiet unless something unplanned happens. Keep a copy of the database off the server too: an attacker with root could rewrite the local copy. Copying it to your workstation with scp after each update is enough for most setups.
How do I reduce noise in the reports?
Exclude paths that change all the time and add the ones that matter for your app. Rules use a leading ! to skip a path and a selection line with a rule group to watch one:
# /etc/aide/aide.conf.d/99_local (Debian, Ubuntu) or append to /etc/aide.conf
!/var/log
!/var/cache
!/var/lib/docker
/srv/app/bin R
/etc/nginx RR is a predefined group covering permissions, ownership, size, checksums and more. Test the syntax with sudo aide --config-check (add --config /etc/aide/aide.conf on Debian), then rebuild the baseline. Watching web upload folders usually generates noise; watching code and config folders gives useful alerts.
How do I set up Tripwire on Ubuntu or Debian?
Install the package and answer the prompts to create a site key and a local key with passphrases you store safely:
sudo apt install tripwire
sudo twadmin --create-polfile -S /etc/tripwire/site.key /etc/tripwire/twpol.txt
sudo tripwire --init
sudo tripwire --checkThe sample policy watches many files that do not exist on a minimal server, so the first check prints a lot of errors. Edit /etc/tripwire/twpol.txt, comment out missing paths, recreate the signed policy with the twadmin line above and run --init again. After planned changes, accept them with sudo tripwire --update --twrfile followed by the newest report in /var/lib/tripwire/report/.
What should I do when a report shows an unexpected change?
Treat it as an incident until proven otherwise. Check which package owns the file (dpkg -S path or rpm -qf path), verify package files with sudo debsums -s on Debian and Ubuntu or sudo rpm -Va on Rocky and Alma, and read the login history with last and the journal. If you cannot explain the change, the safest path is a clean redeploy: install a fresh image, restore data from a backup made before the change, and rotate every credential the server held.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
| Plan | Fits because | Size | Monthly | Order from |
|---|---|---|---|---|
| A1-2 | enough memory for hashing runs beside a small app | 1 vCPU, 2 GB RAM, 50 GB NVMe | $7.20/mo | $43.20 for 6 months |
Questions about File integrity checks with AIDE and Tripwire
How long does an AIDE check take?
It depends on how many files you watch and disk speed. A minimal server finishes in a minute or two; large code trees take longer. Excluding logs and caches speeds it up.
Does AIDE use a lot of resources?
It reads files and computes hashes, so CPU and disk are busy during the run, then it exits. Schedule it at a quiet hour. Memory use stays modest.
Can an attacker hide changes from AIDE?
With root access they could rewrite the database. Keep an offline copy of the baseline and compare against it, or use Tripwire signed databases, to make that harder.
Should I watch /var/www?
Watch code and config folders; skip upload and cache folders that change every day. Too many expected changes make people ignore the report.
Is AIDE available on FreeBSD?
Yes, as a port and package, but this guide covers the Linux packages only. Paths and scheduling differ on FreeBSD.
More in Security
- UFW firewall on Ubuntu and Debian
- firewalld on Rocky Linux and AlmaLinux
- iptables rules that survive a reboot
- Block brute force logins with fail2ban
- CrowdSec intrusion prevention
- Two-factor SSH logins with TOTP
- Disable or restrict root login
- Alerts for every SSH login
- Advanced OpenSSH settings
- Publish SSH host keys in DNS (SSHFP)
- Audit open ports with nmap
- CSF firewall (ConfigServer Security)
- First security steps on Rocky and Alma
- Free TLS certificates with Certbot
- Self-signed certificates and a private CA
- Rate and connection limits in Nginx
- Wazuh security monitoring
- Kernel and sysctl hardening