$linuxjunkies
>

auditctl(8)

Configure and manage the Linux audit daemon to log system calls and file access for security monitoring.

UbuntuDebianFedoraArch

Synopsis

auditctl [OPTION]... [RULE]...

Description

auditctl is the primary tool for configuring the Linux audit framework (auditd). It allows administrators to define rules that monitor system calls, file access, and other security-relevant events. Rules are loaded into the kernel and persist until the audit daemon is restarted or rules are explicitly removed.

Rules can target specific syscalls, files, directories, or attributes. Audit logs are written to /var/log/audit/audit.log and can be analyzed with ausearch and aureport.

Changes made with auditctl are temporary by default; for persistent rules across reboots, add them to /etc/audit/rules.d/audit.rules.

Common options

FlagWhat it does
-a action,filterAdd a rule; action is always or never, filter is task/entry/exit/user-defined
-dDelete all rules and reset audit to disabled state
-DDelete all rules (same as -d but leaves audit enabled)
-w path -p permissionsWatch a file or directory; permissions are r(read), w(write), x(execute), a(attribute)
-S syscallSpecify which syscall(s) to audit; can be used multiple times
-F field=valueFilter rule by field (e.g., uid=0, comm=bash, arch=b64)
-k keynameAssign a label/key to the rule for easier log searching and filtering
-lList all currently loaded audit rules
-m textSend a message to the audit log
-b backlog_limitSet kernel audit buffer size (number of messages)
-f failure_modeSet failure handling: 0=silent, 1=printk, 2=panic
-e statusSet audit status: 0=disabled, 1=enabled, 2=immutable/locked

Examples

List all currently active audit rules

auditctl -l

Monitor /etc/passwd for writes and attribute changes, tagged as 'passwd_changes'

auditctl -w /etc/passwd -p wa -k passwd_changes

Audit all execve syscalls from user 1000 on 64-bit systems

auditctl -a always,exit -F arch=b64 -S execve -F uid=1000 -k user_commands

Watch /tmp directory for all operations (read, write, execute, attribute changes)

auditctl -w /tmp/ -p rwxa -k tmp_monitoring

Audit all file opens in /var/log directory

auditctl -a always,exit -F arch=b64 -S open,openat -F dir=/var/log -k log_access

Delete all rules and disable the audit subsystem

auditctl -d

Write a message to the audit log

auditctl -m 'Audit rules reloaded at system startup'

Make audit configuration immutable (requires reboot to change)

auditctl -e 2

Related commands