ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

auditd and AIDE: who touched what

Lesson 11.19 minAdvancedDecember 1, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • auditd runs by default on RHEL; its log is /var/log/audit/audit.log (SELinux AVC messages are here too).
  • A file watch rule: auditctl -w /etc/passwd -p wa -k identity; permanent rules go in /etc/audit/rules.d/*.rules + augenrules --load.
  • Search: ausearch -k identity -i, report: aureport --summary; auid shows the real logged-in user even after sudo.
  • AIDE is a database of file fingerprints: aide --init → put the database in place → aide --check shows what changed.
  • After an expected change (e.g. dnf update), refresh the database with aide --update; keep a copy of the database off the server.

Two tools, two questions

ToolQuestionHow it works
auditdWho touched it, when, with which command?Records kernel events as they happen
AIDEWhat changed?Compares file hashes and attributes with a database

auditd catches an event the moment it happens; AIDE checks afterwards. One answers "who", the other "what" — together they give the full picture.

auditd

On RHEL 9 auditd is installed and running:

srv-web01
[ali@srv-web01 ~]$ systemctl is-active auditd
active
[ali@srv-web01 ~]$ sudo auditctl -s
enabled 1
failure 1
pid 812
backlog_limit 8192
lost 0
backlog 0
[ali@srv-web01 ~]$ sudo auditctl -l
No rules

No rules means there are no file watch rules, but logins, sudo and SELinux events are still recorded.

Adding a rule

srv-web01
[ali@srv-web01 ~]$ sudo auditctl -w /etc/passwd -p wa -k identity
[ali@srv-web01 ~]$ sudo auditctl -w /etc/httpd/conf.d/ -p wa -k httpd-conf
[ali@srv-web01 ~]$ sudo auditctl -l
-w /etc/passwd -p wa -k identity
-w /etc/httpd/conf.d -p wa -k httpd-conf
PartMeaning
-w pathWatch this file or folder
-p waPermissions: w write, a attribute change, r read, x execute
-k keyA name for searching

A rule added with auditctl is lost on reboot. To make it permanent, write it to a file:

srv-web01
[ali@srv-web01 ~]$ sudo tee /etc/audit/rules.d/itnuvo.rules <<'EOF'
-w /etc/passwd -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/sudoers -p wa -k sudoers
-w /etc/sudoers.d/ -p wa -k sudoers
-w /etc/httpd/conf.d/ -p wa -k httpd-conf
EOF
[ali@srv-web01 ~]$ sudo augenrules --load
[ali@srv-web01 ~]$ sudo auditctl -l

auditd cannot be restarted with systemctl restart (its unit file forbids it) — use augenrules --load for rules and, if needed, sudo service auditd restart.

Searching

Let someone touch /etc/passwd:

srv-web01
[ali@srv-web01 ~]$ sudo useradd testuser
[ali@srv-web01 ~]$ sudo ausearch -k identity -i --start today
----
type=PROCTITLE msg=audit(12/01/2026 14:22:05.311:1842) : proctitle=useradd testuser
type=PATH msg=audit(12/01/2026 14:22:05.311:1842) : item=1 name=/etc/passwd ...
type=SYSCALL msg=audit(12/01/2026 14:22:05.311:1842) : arch=x86_64 syscall=openat success=yes ... auid=ali uid=root ... comm=useradd exe=/usr/sbin/useradd key=identity
FieldMeaning
auid=aliWho logged in (audit user id) — does not change after sudo
uid=rootWhich user the command ran as
comm, exeWhich program
success=yesThe operation succeeded
key=identityWhich rule caught it

auid is the most important field: even if everyone becomes root with sudo, you know who did it.

srv-web01
[ali@srv-web01 ~]$ sudo aureport --summary
[ali@srv-web01 ~]$ sudo aureport -au --start today
[ali@srv-web01 ~]$ sudo aureport -k --start today
[ali@srv-web01 ~]$ sudo ausearch -m USER_LOGIN --success no -i --start today

The last one shows today's failed logins. SELinux denials are here too: ausearch -m AVC -ts recent.

AIDE

srv-web01
[ali@srv-web01 ~]$ sudo dnf install -y aide
[ali@srv-web01 ~]$ sudo aide --init
Start timestamp: 2026-12-01 14:30:12 +0400 (AIDE 0.16)
AIDE initialized database at /var/lib/aide/aide.db.new.gz
...
[ali@srv-web01 ~]$ sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

--init creates a new database, but AIDE reads aide.db.gz when checking — so we rename it. What is watched is set in /etc/aide.conf (by default /etc, /boot, /usr/bin, /usr/sbin and more).

Checking

srv-web01
[ali@srv-web01 ~]$ sudo sed -i 's/^#Port 22/Port 22/' /etc/ssh/sshd_config
[ali@srv-web01 ~]$ sudo aide --check
AIDE found differences between database and filesystem!!

Summary:
  Total number of entries:      45210
  Added entries:                0
  Removed entries:              0
  Changed entries:              1

---------------------------------------------------
Changed entries:
---------------------------------------------------

f   ...    .C... : /etc/ssh/sshd_config
...

C means the content hash changed. If the change was expected (you made it, or there was a dnf update), refresh the database:

srv-web01
[ali@srv-web01 ~]$ sudo aide --update
[ali@srv-web01 ~]$ sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

Automating and protecting the database

srv-web01
[ali@srv-web01 ~]$ echo '30 4 * * * root /usr/sbin/aide --check' | sudo tee /etc/cron.d/aide

If an attacker has become root, they can change the AIDE database too. So after each refresh keep a copy of the database off the server (on another server, on read-only media), and when in doubt run the check against that copy.

Lab: set up monitoring

On your own VM:

  1. Write rules for /etc/passwd, /etc/shadow and /etc/sudoers in /etc/audit/rules.d/itnuvo.rules and run augenrules --load.
  2. Run sudo useradd labtest and see with ausearch -k identity -i that auid is your name.
  3. Look at aureport --summary and the report of failed logins.
  4. Install AIDE, create the database and put it in place.
  5. Add a line to /etc/motd; aide --check should show it; then refresh the database.
srv-web01
[ali@srv-web01 ~]$ sudo auditctl -l
[ali@srv-web01 ~]$ sudo ausearch -k identity -i --start today
[ali@srv-web01 ~]$ sudo aide --check

Check: in the ausearch output auid= is your user, and aide --check shows /etc/motd as changed.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1Where is the auditd log kept?

SELinux AVC messages are here too.

2In the rule auditctl -w /etc/passwd -p wa -k identity, what does -p wa mean?

r is read, x is execute.

3Which field in the audit log shows a user who became root with sudo?

auid does not change after login.

4What does AIDE do?

--init, then --check.

5After dnf update AIDE shows many changes. The right step?

Then put the new database in place.
Was this lesson useful?

Comments

Sign in to comment.