Skip to content

auditd

150 commands

The Linux Audit daemon: records system calls, file access and command execution according to rules, for compliance and detection.

  • Linux
  • auditing
  • detection

Install auditd

sudo apt install auditd

Service Management7

systemctl status auditd

Checks the current operational status of the audit daemon service.

systemctl start auditd

Starts the audit daemon if it is currently stopped.

systemctl stop auditd

Stops the audit daemon service completely.

systemctl restart auditd

Restarts the audit daemon to reload configurations.

systemctl enable auditd

Enables the audit daemon to start automatically at system boot.

service auditd rotate

Forces the rotation of audit log files immediately.

service auditd resume

Resumes logging after auditd was suspended due to disk space issues.

Audit Control8

auditctl -s

Displays the current status, variables, and settings of the kernel audit system.

auditctl -e 1

Enables the audit system if it has been disabled.

auditctl -e 0

Temporarily disables the audit system and stops logging.

Link
auditctl -e 2

Locks the audit configuration so it cannot be changed until reboot.

Link
auditctl -b 8192

Increases the audit buffer size to 8192 messages to prevent loss.

Link
auditctl -f 1

Sets failure mode to print a message to syslog on critical errors.

Link
auditctl -f 2

Sets failure mode to trigger a kernel panic on critical errors.

Link
auditctl -r 0

Disables the rate limit for generated audit messages.

Link

Rule Management2

auditctl -l

Lists all currently loaded audit rules.

Link
auditctl -D

Deletes all currently loaded audit rules.

Link

File Monitoring5

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

Watches /etc/passwd for write or attribute changes and tags with key.

Link
auditctl -w /etc/shadow -p wa -k shadow_access

Watches /etc/shadow for write or attribute changes.

Link
auditctl -w /bin/bash -p x -k shell_exec

Logs every execution of the bash binary.

Link
auditctl -w /etc/sudoers -p wa -k sudo_mod

Monitors the sudoers file for unauthorized modifications.

Link
auditctl -W /etc/passwd

Removes the watch rule specifically for /etc/passwd.

Link

Syscall Auditing7

auditctl -a always,exit -F arch=b64 -S openat -k file_open

Audits the openat syscall on 64-bit architecture upon exit.

Link
auditctl -a always,exit -F arch=b64 -S execve -k process_spawn

Audits process creation via execve on 64-bit systems.

Link
auditctl -a always,exit -F arch=b64 -S unlink -S rmdir -k deletion

Audits file and directory deletion events.

Link
auditctl -a always,exit -F arch=b64 -S chmod -S fchmod -S chown -k perm_mod

Audits changes to file permissions or ownership.

Link
auditctl -a always,exit -F arch=b64 -S mount -S umount2 -k storage_mount

Audits mounting and unmounting of filesystems.

Link
auditctl -a always,exit -F arch=b64 -S settimeofday -S clock_settime -k time_change

Audits attempts to change the system time.

Link
auditctl -a always,exit -F arch=b64 -S init_module -S delete_module -k kernel_mod

Audits loading and unloading of kernel modules.

Link

User Monitoring4

auditctl -a always,exit -F arch=b64 -S all -F auid=1001 -k user_monitor

Audits all syscalls made by the user with Audit UID 1001.

Link
auditctl -a always,exit -F arch=b64 -S execve -F uid=0 -k root_exec

Audits command execution attempted by the root user.

Link
auditctl -a always,exit -F arch=b64 -S all -F gid=100 -k group_monitor

Audits all actions performed by members of GID 100.

Link
auditctl -a always,exit -F arch=b64 -S execve -F euid=0 -k effective_root

Audits executions where the effective user ID is root.

Link

Filter Optimization2

auditctl -a always,exit -F arch=b64 -S open -F success=0 -k open_fail

Only audits open syscalls that result in failure.

Link
auditctl -a always,exit -F arch=b64 -S open -F auid>=1000 -F auid!=4294967295 -k human_activity

Audits file opens by real human users, ignoring daemons and unset AUIDs.

Link

Network Auditing3

auditctl -a always,exit -F arch=b64 -S connect -k net_connect

Audits outgoing network connection attempts.

Link
auditctl -a always,exit -F arch=b64 -S accept -k net_accept

Audits incoming network connection acceptances.

Link
auditctl -a always,exit -F arch=b64 -S bind -k net_bind

Audits attempts to bind a socket to a local address or port.

Link

Persistent Configuration2

augenrules --load

Compiles rules from /etc/audit/rules.d/ and loads them into the kernel.

Link
augenrules --check

Checks if the rules in kernel memory match the persistent configuration.

Link

Log Searching15

ausearch -m USER_LOGIN

Searches logs for user login events.

Link
ausearch -m USER_AUTH

Searches logs for authentication attempts.

Link
ausearch -m SYSCALL -sv no

Searches for system call events that failed.

Link
ausearch -ua 1000

Searches for events triggered by the user with UID 1000.

Link
ausearch -k passwd_changes

Searches for events tagged with the key 'passwd_changes'.

Link
ausearch -f /etc/shadow

Searches for any events related to the file /etc/shadow.

Link
ausearch -p 1234

Searches for events generated by process ID 1234.

Link
ausearch -ts today

Searches for events that occurred today.

Link
ausearch -ts recent

Searches for events that occurred in the last 10 minutes.

Link
ausearch -ts 08:00:00 -te 17:00:00

Searches for events between 8 AM and 5 PM today.

Link
ausearch -tm pts/0

Searches for events originating from terminal pts/0.

Link
ausearch -i -k shell_exec

Searches for 'shell_exec' events and interprets numeric IDs to names.

Link
ausearch -x /usr/bin/passwd

Searches for execution events of the passwd binary.

Link
ausearch -c httpd

Searches for events generated by the command name 'httpd'.

Link
ausearch --raw

Outputs search results in raw format suitable for parsing.

Link

Reporting15

aureport

Generates a general summary report of all audit events.

Link
aureport -au

Generates a report of all authentication attempts.

Link
aureport -l

Generates a report of all login events.

Link
aureport -p

Generates a report of process related events.

Link
aureport -f

Generates a report of all file related events.

Link
aureport -u

Generates a report summarizing events by user.

Link
aureport -s

Generates a report summarizing system call events.

Link
aureport -t

Generates a report of events by log time range.

Link
aureport -c

Generates a report of configuration change events.

Link
aureport -m

Generates a report of account modification events.

Link
aureport -x

Generates a report of executable execution events.

Link
aureport --failed

Generates a summary report of only failed events.

Link
aureport --success

Generates a summary report of only successful events.

Link
aureport -ts yesterday -te today

Generates a report covering events from yesterday to today.

Link
aureport -u -i

Generates a user summary report with numeric IDs resolved to names.

Link

Advanced Rules8

auditctl -a always,exit -F arch=b64 -S ptrace -k tracing

Audits attempts to trace processes (often used by debuggers or malware).

Link
auditctl -a always,exit -F arch=b64 -S mknod -S mknodat -k special_files

Audits creation of special device files.

Link
auditctl -a always,exit -F arch=b64 -S rename -S renameat -k file_rename

Audits file renaming operations.

Link
auditctl -a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time_modification

Audits advanced time adjustment syscalls.

Link
auditctl -a always,exit -F arch=b64 -S swapon -S swapoff -k swap_mod

Audits enabling or disabling of swap space.

Link
auditctl -w /var/log/audit/ -p wa -k audit_log_tampering

Watches the audit log directory itself for tampering attempts.

Link
auditctl -w /sbin/insmod -p x -k module_insertion

Watches the insmod binary for execution.

Link
auditctl -w /sbin/rmmod -p x -k module_removal

Watches the rmmod binary for execution.

Link

Process Tracing2

autrace /bin/ls

Traces the 'ls' command and logs all its syscalls.

Link
autrace -r /usr/bin/python3 script.py

Traces a python script execution including resource usage.

Link

SOC Workflow5

ausearch -k net_connect | aureport -f -i

Finds network connection events and reports which files (sockets) were accessed.

Link
ausearch -ul 1000 -m USER_LOGIN -i

Investigates all login events for a specific user ID.

Link
ausearch -k passwd_changes -ts today | aureport -u -i

Identifies which users modified password files today.

Link
ausearch -m PROCTITLE -i

Searches for events containing process title information (command line args).

Link
ausearch -k root_exec -i | grep ' /bin/bash'

Filters root execution logs specifically for bash shells.

Link

Blue Team Validation5

auditctl -s | grep 'enabled'

Validates that the audit service is currently enabled.

Link
ausearch -m DAEMON_ABORT

Checks logs for instances where the audit daemon crashed or aborted.

Link
ausearch -m ANOM_PROMISCUOUS

Searches for network interfaces entering promiscuous mode (sniffing).

Link
ausearch -m ANOM_ABEND

Searches for applications that terminated abnormally (segfaults).

Link
ausearch -f /root/.ssh/authorized_keys -i

Monitors access to root SSH keys for unauthorized persistence.

Link

Compliance5

auditctl -a always,exit -F arch=b64 -S fchown -S fchownat -k ownership_change

Compliance rule to track all file ownership changes.

Link
auditctl -a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -k attr_mod

Compliance rule to track extended attribute modifications.

Link
auditctl -w /var/log/tallylog -p wa -k logins

Monitors the tallylog file for failed login attempt tracking.

Link
auditctl -w /etc/group -p wa -k group_mod

Monitors the group file for changes to user groups.

Link
auditctl -w /etc/issue -p wa -k banner_mod

Monitors changes to the system login banner.

Link

Incident Response7

ausearch --start recent -m EXECVE -i | grep 'nc -e'

Hunts for recent executions of netcat reverse shells.

Link
ausearch -f /tmp -i | grep 'EXECVE'

Investigates any binaries executed from the /tmp directory.

Link
ausearch -f /dev/shm -i

Checks for suspicious file activity in shared memory (malware staging).

Link
ausearch -k kernel_mod -i

Checks for unauthorized kernel module loading (rootkits).

Link
ausearch -m USER_CMD -i --failed

Reviews failed sudo commands to detect privilege escalation attempts.

Link
ausearch -ts today -m LOGIN -F success=no

Lists all failed login attempts from the current day.

Link
ausearch -k deletion -i | grep '/var/log'

Detects attempts to delete log files to cover tracks.

Link

Advanced Filtering6

auditctl -a always,exit -F arch=b64 -S socket -F a0=2 -k ipv4_socket

Audits creation of IPv4 sockets specifically.

Link
auditctl -a always,exit -F arch=b64 -S socket -F a0=10 -k ipv6_socket

Audits creation of IPv6 sockets specifically.

Link
auditctl -a always,exit -F dir=/home -F uid=0 -C auid!=obj_uid -k admin_home_access

Audits root accessing home directories not belonging to them.

Link
auditctl -a always,exit -F arch=b64 -S execve -F exe=/usr/bin/wget -k suspicious_download

Specifically audits execution of wget.

Link
auditctl -a always,exit -F arch=b64 -S execve -F exe=/usr/bin/curl -k suspicious_download

Specifically audits execution of curl.

Link
auditctl -a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ncat -k reverse_shell_tool

Audits ncat execution, often used for reverse shells.

Link

Configuration Maintenance3

sh -c 'auditctl -R /etc/audit/audit.rules'

Manually reloads rules from the legacy audit.rules file.

Link
grep -i 'backlog' /var/log/syslog

Checks system logs for audit backlog limit exceeded warnings.

Link
auditctl -m 'Audit checkpoint: System update started'

Injects a custom text message into the audit log for marking events.

Link

Automated Analysis5

aureport --summary

Provides a high-level statistical summary of all audit events.

Link
ausearch -te now -ts recent -i | aureport -f

Pipelines recent logs into a file access report.

Link
ausearch -k deletion | aureport -f -i

Reports exactly which files were deleted based on the deletion key.

Link
ausearch -m AVC -i

Searches for SELinux Access Vector Cache denials.

Link
ausearch -m USER_TTY -i

Searches for TTY (terminal) allocation events.

Link

Deep Dive5

auditctl -a always,exit -F arch=b64 -S clone -S fork -S vfork -k process_fork

Audits all process forking methods.

Link
auditctl -a always,exit -F arch=b64 -S kill -k process_kill

Audits the kill syscall to track process termination signals.

Link
auditctl -a always,exit -F arch=b64 -S ptrace -F a0=4 -k process_injection

Audits PTRACE_POKETEXT/DATA calls, indicative of code injection.

Link
auditctl -a always,exit -F arch=b64 -S memfd_create -k memory_exec

Audits creation of memory file descriptors, used by fileless malware.

Link
auditctl -a always,exit -F arch=b64 -S prctl -k process_control

Audits process control operations.

Link

Immutable Systems1

sed -i 's/immutable = 0/immutable = 1/' /etc/audit/auditd.conf

Configures auditd to start in immutable mode via config file.

Link

Log Management4

grep 'max_log_file' /etc/audit/auditd.conf

Checks the maximum size of a single audit log file.

Link
grep 'max_log_file_action' /etc/audit/auditd.conf

Checks what action auditd takes when a log file fills up.

Link
grep 'space_left_action' /etc/audit/auditd.conf

Checks action taken when disk space is running low.

Link
grep 'admin_space_left_action' /etc/audit/auditd.conf

Checks action taken when disk space is critically low.

Link

Real-time Monitoring2

tail -f /var/log/audit/audit.log

Tails the raw audit log file for real-time observation.

Link
tail -f /var/log/audit/audit.log | ausearch -i

Tails the log and pipes it to ausearch for real-time interpretation.

Link

Log Decoding2

ausearch -i -f /usr/bin/sudo | less

Pages through interpreted audit logs related to sudo execution.

Link
aureport --node

Reports events by node name (useful in clustered environments).

Link

Privilege Auditing2

auditctl -a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation

Audits explicit calls to set user or group identity.

Link
auditctl -a always,exit -F arch=b64 -S capset -k capability_change

Audits changes to process capabilities.

Link

Filesystem Integrity2

auditctl -w /boot/ -p wa -k boot_integrity

Monitors the boot directory for modifications (kernel tampering).

Link
auditctl -w /lib64/ld-linux-x86-64.so.2 -p wa -k library_hijack

Monitors the dynamic linker for tampering.

Link

Complex Queries4

ausearch -k user_monitor -ts today -te 12:00:00

Filters user monitor events for the morning session only.

Link
ausearch -m CRYPTO_KEY_USER

Searches for events related to cryptographic key usage.

Link
ausearch -m SERVICE_START -i

Searches for service start events.

Link
ausearch -m SERVICE_STOP -i

Searches for service stop events.

Link

Container Auditing3

auditctl -a always,exit -F arch=b64 -S unshare -k container_creation

Audits namespace unsharing, often used in container creation.

Link
auditctl -a always,exit -F arch=b64 -S setns -k container_entry

Audits entry into an existing namespace (container exec).

Link
auditctl -a always,exit -F arch=b64 -S pivot_root -k container_pivot

Audits pivoting of the root filesystem.

Link

Search Optimization2

ausearch --checkpoint ./checkpoint.txt

Performs a search and saves a checkpoint to resume later.

Link
ausearch --checkpoint ./checkpoint.txt --resume

Resumes a search from the saved checkpoint file.

Link

Automation3

ausearch -ts today -m AVC --raw | audit2allow

Pipes raw AVC denials to audit2allow to generate SELinux policies.

Link
aureport --input /var/log/audit/audit.log.1

Generates a report from a rotated (archived) log file.

Link
ausearch -if /var/log/audit/audit.log.1 -m LOGIN

Searches for login events within a specific rotated log file.

Link

Cleanup4

auditctl -D

Removes all rules in preparation for a clean shutdown or reset.

Link
systemctl stop auditd

Stops the daemon after testing is complete.

Link
rm /etc/audit/rules.d/test.rules

Removes temporary test rule files.

Link
augenrules --load

Reloads the default configuration to restore system state.

Link