Port Igniter
Get Started

Basic Commands for AuditD

An easy to follow guide on how to get the most out of AuditD on your Linux system

May 30, 2026

AuditD - Basic Commands for the standard Auditing Linux Service Daemon

In this snippet we’re going to cover some practical examples of using auditd tools like ausearch, aureport, and auditctl, with a focus on isolating keys, filtering events, time-based queries, and other useful scenarios. Audit logs are only readable by root, so every command here is run with sudo.

This article was updated on 21 November 2026. The examples were tested with audit 4.2.1. Option names are the same on older 3.x releases.

ausearch Examples

Search by Time Range

# Search an exact window: the date and time are separate arguments
sudo ausearch --start 10/01/2023 00:00:00 --end 10/02/2023 00:00:00

# Short forms of the same options
sudo ausearch -ts 10/01/2023 00:00:00 -te 10/02/2023 00:00:00

# Keywords: recent means the last 10 minutes
sudo ausearch -ts recent
sudo ausearch -ts today
sudo ausearch -ts yesterday -te today
sudo ausearch -ts this-week

The date format follows your locale (the example above is US English). Run date '+%x' to see the format your system expects. Other keywords are now, this-hour, boot, week-ago, this-month and this-year. Use 24 hour times; AM and PM are not accepted.

Make the Output Readable

# Translate numbers (user IDs, syscalls, times) into names
sudo ausearch -ts today -i

# One plain English sentence per event
sudo ausearch -ts today --format text

# Normalized CSV columns, ready for a spreadsheet
sudo ausearch -ts today --format csv

--format accepts raw, default, interpret, csv and text. There is no option to pick individual fields; use --format csv and choose the columns in your spreadsheet, or use grep on interpreted output as shown below.

Filter by Key, User, Program or File

# Events caught by rules tagged with a key
sudo ausearch -k identity -i

# Events for the person who logged in as alice (the audit or login user ID)
sudo ausearch -ul alice -i

# Events where the process ran as a given user ID
sudo ausearch -ui 1001 -i

# Events from one program
sudo ausearch -x /usr/bin/chmod -i

# Events that touched a file
sudo ausearch -f /etc/passwd -i

# Events for one system call, by name
sudo ausearch -sc openat -i

# Only failed events
sudo ausearch -sv no -i

# One record type, such as logins
sudo ausearch -m USER_LOGIN -i

All filters can be combined, and every one of them must match. Note that only the last -k counts if you give more than one, so run one search per key.

Combine with grep or awk

# Pull the command lines of every chmod run today
sudo ausearch -x /usr/bin/chmod -ts today -i | grep proctitle

# Print just the user and program from each SYSCALL record
sudo ausearch -k identity -i | awk '/type=SYSCALL/ {for (i=1;i<=NF;i++) if ($i ~ /^(auid|exe)=/) printf "%s ", $i; print ""}'

# Search interpreted output for any mention of a file
sudo ausearch -ts today -i | grep "/etc/shadow"

Raw Output

# The exact log lines, useful for saving evidence or piping into aureport
sudo ausearch -ts today --raw

Raw output is the original audit log text, not JSON, so it is not suitable for jq. For structured data, use --format csv.

aureport Examples

Generate Reports

# A summary of everything in the logs: start here
sudo aureport --summary -i

# Report on users with audit events
sudo aureport -u -i

# Report on remote hosts in login and authentication events
sudo aureport -h -i

# Every event, one per line
sudo aureport -e -i

# Logins and authentication attempts
sudo aureport -l -i
sudo aureport -au -i

# Changes to accounts and groups
sudo aureport -m -i

# Programs run and files touched
sudo aureport -x --summary -i
sudo aureport -f --summary -i

# Events per rule key
sudo aureport -k --summary -i

# Only failed events, for any report
sudo aureport -au --failed -i

Filter by Time Range

# Report events from a 7 day window
sudo aureport -ts 10/01/2023 -te 10/08/2023 --summary -i

# Report failed logins from the last 10 minutes
sudo aureport -ts recent -l --failed -i

# Show the time range covered by each log file
sudo aureport -t

Summarize Just the Events You Searched For

aureport does not choose output fields, but it reads raw events from a pipe, so you can summarize exactly what ausearch found:

# Which programs did rules keyed "exec" catch this week?
sudo ausearch -k exec -ts this-week --raw | sudo aureport -x --summary -i

Combine with grep

# Find chmod in the executable report
sudo aureport -x -i | grep chmod

Time-Based Queries with ausearch

# Find events between specific times
sudo ausearch -ts 10/01/2023 12:00:00 -te 10/01/2023 13:00:00 -i

# Find events from the last 10 minutes
sudo ausearch -ts recent -i

# Find events since the system last booted
sudo ausearch -ts boot -i

Other Useful Commands

List All Audit Rules

sudo auditctl -l

Check Audit Daemon Status

# The service
systemctl status auditd

# The kernel side: "lost" should be 0
sudo auditctl -s

Monitor Live Audit Events

ausearch has no live mode, but it reads from a pipe, and -l prints each event as soon as it is complete:

sudo tail -n0 -F /var/log/audit/audit.log | sudo ausearch --format text -l

Export Logs to a File

# Readable text
sudo ausearch -ts yesterday -te today -i > audit_log.txt

# Exact raw lines, for evidence or for analysis on another machine
sudo ausearch -ts yesterday -te today --raw > audit_log.raw

# Search a saved file later (root is not needed for this)
ausearch -if audit_log.raw -i

Manage Old Logs

ausearch only reads logs; it cannot delete them. auditd rotates its own logs based on /etc/audit/auditd.conf:

# Size of each log file in MB
max_log_file = 100
# How many rotated files to keep
num_logs = 20
max_log_file_action = ROTATE
# Apply the new settings
sudo service auditd restart

# Rotate the log right now
sudo auditctl --signal rotate

Advanced Tips

  • Use --format csv for structured data. Add --extra-time and --extra-keys for more columns:
    sudo ausearch -ts today --format csv --extra-time --extra-keys > events.csv
    
  • Combine with audit2allow to generate SELinux policy modules from denials (AVC records):
    sudo ausearch -m AVC -ts recent | audit2allow
    
  • Use auditctl to Add Rules, and always give them a key so you can find their events:
    # Temporary (until reboot or the next rule reload)
    sudo auditctl -w /etc/passwd -p wa -k identity
    
    # Permanent: add the rule to a file in /etc/audit/rules.d/, then load it
    echo '-w /etc/passwd -p wa -k identity' | sudo tee /etc/audit/rules.d/50-identity.rules
    sudo augenrules --load
    
    The permissions are r (read), w (write), x (execute) and a (attribute change).

Example: Find All File Access Events for a Specific User

sudo ausearch -ul alice -ts yesterday -i | grep -E 'type=PATH|type=SYSCALL'

Or, as one sentence per event:

sudo ausearch -ul alice -ts yesterday --format text

This outputs:

At 08:02:02 10/01/2023 alice, acting as root, successfully opened-file /etc/passwd using /usr/bin/vi

Example: Extract All chmod Actions in the Last Hour

sudo ausearch -x /usr/bin/chmod -ts this-hour --format text

Example: Generate a CSV Report of All Events

sudo ausearch -ts today --format csv > audit_report.csv

The audit subsystem in Linux (via auditd) logs detailed events in a structured format. One event is usually several records (lines) that share the same timestamp and serial number. Below are the key fields you will find in those records, and how to search on them with ausearch.

Anatomy of an Audit Event

Here is a real event from /var/log/audit/audit.log. Long lines are wrapped here; on disk each record is one line.

type=SYSCALL msg=audit(1696166400.418:4821): arch=c000003e syscall=59 success=yes exit=0
  a0=55d1c2a3b0f0 a1=55d1c2a3b2a0 a2=55d1c2a2e010 a3=8 items=2 ppid=2201 pid=2245
  auid=1001 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=7
  comm="useradd" exe="/usr/sbin/useradd" key="root-cmd"
type=EXECVE msg=audit(1696166400.418:4821): argc=3 a0="useradd" a1="-m" a2="backup"
type=CWD msg=audit(1696166400.418:4821): cwd="/root"
type=PATH msg=audit(1696166400.418:4821): item=0 name="/usr/sbin/useradd" inode=1312877
  dev=fd:00 mode=0100755 ouid=0 ogid=0 nametype=NORMAL
type=PROCTITLE msg=audit(1696166400.418:4821): proctitle=75736572616464002D6D006261636B7570

msg=audit(1696166400.418:4821) is the time (seconds since the epoch, with milliseconds) followed by the event serial number. Every record with serial 4821 belongs to the same event. Running ausearch -a 4821 -i shows the whole event with names and a readable time.

Core Fields in an Audit Record

These fields appear in SYSCALL records, the heart of most events:

Field Description Example
auid Audit (login) user ID: the person who logged in. It survives sudo and su. 4294967295 (shown as unset) means no login, such as a service. 1001
uid / euid Real and effective user ID of the process. 0
gid / egid Real and effective group ID. 0
ses Login session ID. 7
pid / ppid Process ID and parent process ID. 2245
tty Terminal, or (none) for background processes. pts1
comm Short command name (up to 15 characters, easy to fake). useradd
exe Full path to the executable. /usr/sbin/useradd
syscall System call number (-i shows the name). 59 (execve)
arch CPU architecture (c000003e is x86_64). c000003e
success / exit Whether the call worked, and its return value or error. yes / 0
a0 to a3 The first four system call arguments, in hex. 55d1c2a3b0f0
key The key of the audit rule that matched. root-cmd

Fields in the Other Records

Record Field Description Example
EXECVE argc, a0, a1 … Number of arguments, then each argument. a1="-m"
CWD cwd Working directory of the process. /root
PATH name Path of a file the call touched (one PATH record per file). /etc/passwd
PATH inode, dev Inode number and device of the file. 1312877
PATH mode File type and permissions. 0100755
PATH ouid, ogid Owner and group of the file. 0
PATH nametype NORMAL, PARENT, CREATE or DELETE. NORMAL
PROCTITLE proctitle Full command line, hex encoded (-i decodes it). useradd -m backup
SOCKADDR saddr Network address used by connect or bind. saddr_fam=inet laddr=192.168.56.110 lport=4433
USER_LOGIN, USER_AUTH acct, addr, res Account, remote address and result of a login or authentication. res=failed

How to Use These Fields

Search on a Field

ausearch has an option for most important fields:

Field ausearch option
auid -ul
uid / euid -ui / -ue
ses --session
pid / ppid -p / -pp
exe / comm -x / -c
syscall -sc
success -sv yes or -sv no
exit -e (a number, such as -e -13 for permission denied)
key -k
name (PATH) -f
tty -tm
record type -m

Extract a Field from Matching Events

# List the file paths from every event caught by the "identity" key
sudo ausearch -k identity -i | grep -o 'name=[^ ]*' | sort | uniq -c

Filtering by Result

# Find failed file opens
sudo ausearch -sc openat -sv no -i

Decode Values by Hand

# A syscall number to its name
ausyscall x86_64 59

# A hex PROCTITLE value to text
echo 75736572616464002D6D006261636B7570 | xxd -r -p | tr '\0' ' '; echo

Notes

  • Field Availability: Not all fields are present in every record. PATH fields only appear when a call touches files, and SOCKADDR only for network calls.
  • Names vs. numbers: -i translates user IDs using the /etc/passwd of the machine you run it on. Set log_format = ENRICHED in /etc/audit/auditd.conf so the log also stores the original names, which keeps them correct when you analyze logs on another machine.
  • Tools: Use ausearch to find and read events and aureport for summaries. man ausearch and man aureport list every option for your version.

These examples should help you efficiently query, analyze, and manage audit logs using auditd tools. A solid AuditD rules file to start from is maintained on Github by Neo23x0. This is a good starting point that covers a lot of the bases out the gate. The audit package also ships sample rule files in /usr/share/audit-rules/ (or /usr/share/audit/sample-rules/ on older releases). If you’re in a Department of Defense (DoD) Environment, be sure to reference requirements listed in the Applicable STIG for your operating system.

Where to go next

If you’re interested, I have written a detailed field guide for Linux administrators and security professionals in the format of a playbook. You can use it to setup your servers up using best practices and speed up your alerting and threat hunting capabilities. It is available on my LMS here.

Think I might be a good fit for your project?

Let's get the conversation started!

Top