Operating System CentOS

How to Set Up AIDE File Integrity Monitoring on AlmaLinux 9 and Rocky Linux 9

Install AIDE on AlmaLinux 9 or Rocky Linux 9, create the baseline database, schedule daily checks and update the baseline after legitimate changes.

AIDE (Advanced Intrusion Detection Environment) records checksums, permissions and other attributes of the files on a system and later reports anything that was added, removed or changed. It will not stop an intruder, but it tells you which files were touched. This guide installs AIDE on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, builds the baseline database, schedules a daily check and shows how to accept legitimate changes. CentOS 6 reached end of life in November 2020 and no longer receives security fixes; the 9 releases of the RHEL family replace it.

Requirements

  • A server running AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9.
  • A user with sudo rights. AIDE has to read every file it monitors, so all commands run as root.
  • Ideally a freshly installed system. A baseline taken from a machine that is already compromised only certifies the compromised state.

Step 1: Install AIDE

sudo dnf install aide

The package comes from the standard repositories. Check which version you received, because configuration syntax differs between the 0.16 and 0.19 series:

rpm -q aide
aide --version

Step 2: Review the configuration

The configuration file is /etc/aide.conf. The packaged file already covers the important system paths (/boot, /etc, the binary and library directories and so on) and excludes volatile ones, so you can start with it unchanged.

Each rule is a path (a regular expression anchored at the start) followed by the attributes to record. To monitor an additional directory, such as a web root, add rules at the end of the file:

/var/www/html p+u+g+s+sha256
!/var/www/html/cache

Here p, u, g and s are permissions, owner, group and size, and sha256 is the checksum. A leading ! excludes a path. Do not monitor content that changes constantly (logs, caches, upload directories, databases): every run would report it and the real findings would drown in noise.

Validate the file after editing it:

sudo aide --config-check

No output means the configuration parsed without errors.

Step 3: Build the baseline database

sudo aide --init

AIDE walks the file system and writes the new database to /var/lib/aide/aide.db.new.gz. This can take several minutes. AIDE reads its reference database from a different file name, /var/lib/aide/aide.db.gz, so the new file has to be put in place before any check works:

sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

The two names exist on purpose: AIDE never overwrites the database it is comparing against, and you decide when a new state becomes the reference.

Step 4: Run a check

sudo aide --check

Right after initialisation the report should say that no differences were found. To see what a finding looks like, create a file in a monitored directory and check again:

sudo touch /etc/aide-test
sudo aide --check
sudo rm /etc/aide-test

The report lists the file under added entries and shows the parent directory /etc as changed, because its modification time moved. The exit status tells scripts what happened: 0 means no differences, and otherwise it is the sum of 1 (new files), 2 (removed files) and 4 (changed files). Values of 14 and above indicate an error, such as an invalid configuration.

Step 5: Schedule a daily check

With the packaged systemd timer

Recent builds of the EL9 package include a ready-made timer that is disabled by default. Find out whether yours has it:

systemctl cat aide-check.timer

If the unit exists, enable it. It runs aide --check once a day at low CPU and I/O priority:

sudo systemctl enable --now aide-check.timer
systemctl list-timers aide-check.timer

Read the results of the latest runs with:

sudo journalctl -u aide-check

With cron

If the timer is not part of your package, or you want the report by email, use a cron entry instead. Cron mails the output of a job to the MAILTO address, provided the server has a working mail transfer agent such as Postfix:

sudo nano /etc/cron.d/aide-check
MAILTO=admin@example.com
5 4 * * * root /usr/sbin/aide --check

This runs the check every day at 04:05. Use one method or the other, not both.

Step 6: Update the baseline after legitimate changes

Package updates, configuration edits and deployments all change monitored files, and they will appear in every report until you accept them. After a planned change, review the report, and if everything in it is expected, create a new database and make it the reference:

sudo aide --update
sudo mv -f /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

aide --update performs a check against the old database and writes the current state to aide.db.new.gz in the same run. A sensible routine is: run aide --check before dnf upgrade to confirm the system is clean, upgrade, then update the baseline immediately.

Protect the database

AIDE does not encrypt or sign its own files. Someone with root access can alter a file and then rebuild the database, or replace the aide binary, and the next check will look clean. The package documentation therefore recommends keeping a copy of the database, the configuration file and the binary (or their checksums) somewhere the server cannot write to. A minimal version is copying the database to another machine after every baseline update:

sudo sha256sum /var/lib/aide/aide.db.gz
sudo scp /var/lib/aide/aide.db.gz deploy@backup.example.com:aide/$(hostname)-aide.db.gz

When you suspect an incident, compare the checksum of the local database with your off-host copy, or restore the copy before running the check.

Troubleshooting

  • The check fails because the database cannot be opened: the baseline was never moved into place. Repeat the mv command from Step 3.
  • Configuration errors after a package upgrade: the 0.19 series renamed some options (for example database became database_in) and dropped several old hash algorithms. Run sudo aide --config-check, and if /etc/aide.conf.rpmnew exists, compare it with your file.
  • Reports are too long to read: exclude the noisy paths with ! rules, rebuild the baseline, and keep the monitored set to files that should rarely change.

Frequently asked questions

Does AIDE detect changes in real time?

No. It compares the file system with the baseline only when a check runs, so a daily schedule means up to a day between a change and the report. For real-time events, the kernel audit subsystem (auditd) can watch specific files; many administrators run both.

Is AIDE still maintained?

Yes. The upstream project publishes releases on GitHub; the 0.19 series is current, with version 0.19.5 dated October 2026 on the project page. Distributions ship their own, often older, builds with security fixes backported.

Does this work on Debian or Ubuntu?

AIDE is packaged there as well, but the layout differs: the configuration lives under /etc/aide, and the package provides wrapper scripts for creating the database and for the daily check. The aide commands themselves behave the same; follow the package's README for the file locations.

How long does a check take?

It depends on how many files are monitored and how fast the disk is, because every monitored file is read and hashed. On a typical small VPS with the default rules it is a matter of minutes. Schedule it outside peak hours.

Share story:

Continue reading other guides on How VPS.