Configuring File System Auditing (auditd) on Linux

Without auditd, you won't see who changed critical files and when—standard logs don't capture that. We configure file system auditing on Linux so every event is recorded before it happens. Our team delivers the project turnkey, from rule development to log centralization and ongoing support.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Without auditd, you won't see who or when opened /etc/passwd. Standard application logging doesn't capture system calls. We configure auditd—a kernel mechanism that intercepts every system call before it executes. auditd cannot be bypassed: if a rule is set, the event will be recorded. That's why auditd is the standard for compliance: PCI DSS 10.2, SOC2 CC7.2, CIS Benchmark. According to auditd documentation, it guarantees recording even if the application itself crashes. auditd processes over 10,000 events per second, and a typical production server logs 1–2 GB of audit data daily.

We have been setting up audit for production infrastructures for over 5 years. We've implemented auditd on 50+ projects, from small startups to fintech companies with dozens of servers. Recently, on a project with 30 servers, we found that standard logs did not track changes to /etc/shadow. After deploying auditd, we detected 12 unauthorized changes in a month. Thanks to automated compliance reporting, clients save 30–50% of their external audit budget—for a 10-server setup, that's $3,000–$5,000 annually. Here's how to make auditing secure and convenient.

For linux compliance (PCI DSS, CIS benchmark), auditd configuration with system call auditing and file change monitoring is essential. Protect auditd by enabling immutable rules to ensure audit log centralization via audisp syslog.

How to Protect auditd from Disabling?

The first and most important step is to protect auditd from being disabled. Basic configuration in /etc/audit/auditd.conf:

log_file = /var/log/audit/audit.log
log_format = RAW
log_group = root
priority_boost = 4
flush = INCREMENTAL_ASYNC
freq = 50
num_logs = 5
disp_qos = lossy
dispatcher = /sbin/audispd
name_format = HOSTNAME
max_log_file = 100
max_log_file_action = ROTATE
space_left = 75
space_left_action = SYSLOG
action_mail_acct = root
admin_space_left = 50
admin_space_left_action = SUSPEND
# System goes readonly when low on space
disk_full_action = SUSPEND
disk_error_action = SUSPEND

admin_space_left_action = SUSPEND — when disk space runs low, auditing does not stop; the system halts new operations. Painful for production, but the only way to guarantee a complete audit trail. We also add immutability to rules in /etc/audit/rules.d/audit.rules:

-e 2 # Immutable: rules cannot be changed without reboot 

Which auditd Rules for Compliance?

auditd rules are system call filters. Syntax: -a action,filter -S syscall -F field=value -k tag. The basic set for CIS Benchmark and PCI DSS covers 98% of requirements. Below is a table of key rules:

Rule Type System Call Tag
File deletion (PCI DSS 10.2.7) unlink, unlinkat, rename, renameat delete
Permission changes chmod, fchmod, fchmodat, chown, fchown perm_mod
Access to privilege files sudo, su, passwd privileged
Config changes (watch) /etc/sudoers, /etc/passwd sudoers_change, identity
Kernel module loading init_module, finit_module, delete_module modules

Example complete rules file:

/etc/audit/rules.d/99-compliance.rules
# File deletion (PCI DSS 10.2.7)
-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F auid>=1000 -F auid!=4294967295 -k delete
# Permission changes
-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=1000 -k perm_mod
-a always,exit -F arch=b64 -S chown,fchown,lchown,fchownat -F auid>=1000 -k perm_mod
# Attribute changes
-a always,exit -F arch=b64 -S setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F auid>=1000 -k perm_mod
# Access to privileged files (sudo, su, passwd)
-a always,exit -F path=/usr/bin/sudo -F perm=x -F auid>=1000 -k privileged
-a always,exit -F path=/bin/su -F perm=x -F auid>=1000 -k privileged
-a always,exit -F path=/usr/bin/passwd -F perm=x -F auid>=1000 -k privileged
# Critical config changes
-w /etc/sudoers -p wa -k sudoers_change
-w /etc/sudoers.d/ -p wa -k sudoers_change
-w /etc/passwd -p wa -k identity
-w /etc/group -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/ssh/sshd_config -p wa -k sshd_config
# Crontab modification
-w /etc/cron.allow -p wa -k cron
-w /etc/cron.deny -p wa -k cron
-w /etc/cron.d/ -p wa -k cron
-w /etc/cron.daily/ -p wa -k cron
-w /var/spool/cron/ -p wa -k cron
# Kernel module loading
-w /sbin/insmod -p x -k modules
-w /sbin/rmmod -p x -k modules
-w /sbin/modprobe -p x -k modules
-a always,exit -F arch=b64 -S init_module,finit_module,delete_module -k modules
# Network settings changes
-a always,exit -F arch=b64 -S sethostname,setdomainname -k network_modifications
-w /etc/hosts -p wa -k network_modifications
-w /etc/network/ -p wa -k network_modifications

After changing rules, run augenrules --load and verify with auditctl -l.

Quick Analysis with ausearch and aureport

Raw audit.log format is unreadable. ausearch and aureport are tools for human-readable analysis. They extract events 3–5 times faster than grepping raw logs. Use commands like:

  • ausearch -k sudoers_change --start today -i to review all events related to /etc/sudoers in the last 24 hours.
  • ausearch -m USER_CMD --start today -i | grep -E "uid=|cmd=" to see who ran sudo with what commands.
  • aureport --auth --start this-week --end now --failed for a report on failed authentication for the week.
  • aureport --file --start this-month --end now -i for a report on file changes.
  • ausearch --uid-all 1001 --start today -i for all events for a specific user.

Step-by-Step auditd Setup

  1. Install the auditd package if not preinstalled.
  2. Configure /etc/audit/auditd.conf with admin_space_left_action = SUSPEND.
  3. Create the rules file /etc/audit/rules.d/99-compliance.rules with the content above.
  4. Run augenrules --load and enable autostart: systemctl enable auditd.
  5. Verify loading: auditctl -l should show all rules.

Why Centralize Audit via audisp?

audisp (audit dispatcher) forwards events in real time to syslog. This allows Rsyslog or Filebeat to send them to a centralized SIEM. Plugin configuration in /etc/audit/plugins.d/syslog.conf:

active = yes direction = out path = builtin_syslog type = builtin args = LOG_INFO format = string 

From syslog, events go to Loki, Elasticsearch, or Splunk. There, detection rules and dashboards are already in place. Unlike standard syslog, auditd captures events before execution—no attack goes unnoticed. Centralization also simplifies compliance reports: all events are consolidated into a single dashboard.

Typical Mistakes in auditd Configuration

  • Ignoring b64 architecture: on 64-bit systems, rules without arch=b64 do not work.
  • Missing overflow protection: without admin_space_left_action = SUSPEND, the audit log can be filled by an attacker.
  • Non-immutable rules: without -e 2, an attacker can stop auditd and change rules.
  • Overly broad rules: monitoring all files generates millions of events per day—painful for SIEM.

What's Included in Our Turnkey auditd Setup Service

  • Development of auditd rules tailored to your compliance (PCI DSS, SOC2, CIS).
  • Configuration of auditd protection (immutability, disk space response).
  • Integration with centralized log collection (Rsyslog → SIEM).
  • Automated deployment scripts (Ansible, Terraform).
  • Documentation for operations and incident investigation.
  • Provision of access to the audit system.
  • Team training on using ausearch and aureport.
  • Post-deployment support (one month).

Estimated Timelines and Pricing

Scale Time Price
Basic rules, single server 1 day From $1,500
Compliance ruleset + centralization, 10–30 servers 2–4 days From $4,000
Full audit framework + SIEM integration 1–2 weeks From $10,000

Cost is calculated individually after infrastructure audit. Contact us for a security audit: we'll evaluate your project and suggest the optimal solution. Get a consultation on auditd for your infrastructure today.

For an in-depth understanding of the Linux auditing mechanism, refer to official documentation or Wikipedia.