Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Trace a Linux Command With autrace and Read the Audit Log

Run autrace in a test environment, find events by process ID, and summarize file activity without removing a host’s existing audit rules.

Table of Contents

autrace runs a command under the Linux Audit framework and records events for that execution. Use it in a disposable test VM with an empty audit ruleset. It requires exclusive use of the ruleset, so use existing audit records or strace when the host already has audit rules.

Autrace - Tool to check, count and monitor Linux processes Picture 1

Trace a command in a test VM

Check that the Linux Audit tools are installed, that auditd is active, and that sudo auditctl -l shows no configured rules. If rules are present, leave them in place and use another machine or another tool. The autrace manual describes the ruleset requirement.

systemctl is-active auditd
sudo auditctl -l
sudo autrace "$(command -v df)" -h

Run the final command only after the checks succeed. It starts a new df process and reports the PID to search for. With auditd active, the default audit log is usually /var/log/audit/audit.log, though local configuration can change it.

Audit and trace screenshots from the original walkthrough

Autrace - Tool to check, count and monitor Linux processes Picture 2

Autrace - Tool to check, count and monitor Linux processes Picture 3

Autrace - Tool to check, count and monitor Linux processes Picture 4

Read events and summarize files

Replace 12345 with the PID that autrace reports. Limiting the search to recent events helps avoid confusing this run with older records that have the same PID.

sudo ausearch --start recent -p 12345 -i
sudo ausearch --start recent -p 12345 --raw | aureport --file --summary

-i interprets numeric audit fields for reading. --raw passes records in the format aureport expects. For a narrower resource-use trace, use autrace -r with the target command on the test system.

Event search and file report screenshots

Autrace - Tool to check, count and monitor Linux processes Picture 5

Autrace - Tool to check, count and monitor Linux processes Picture 6

Autrace - Tool to check, count and monitor Linux processes Picture 7

Autrace - Tool to check, count and monitor Linux processes Picture 8

Autrace - Tool to check, count and monitor Linux processes Picture 9

If the system has existing audit rules, search the events already collected. For a short, authorized syscall trace that doesn’t change the audit ruleset, use strace on a command you start yourself. See the Linux service and log troubleshooting lesson for choosing between service logs and deeper tracing.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.