Module 5 · Linux Forensics — Auditd, journalctl, Containers

Manish Garg
Manish Garg Associate of (ISC)² · RingSafe
May 13, 2026
4 min read
Read as
100% Free

No signup. No paywall. No catch. One of our 10 most-requested practitioner modules — published in full so anyone can learn for free. We earn through consulting, not by gating knowledge.

See all 10 free modules →

Why this module exists. Linux forensics covers a different surface than Windows: bash history, auditd, journalctl, container layers, eBPF probes, and the /proc filesystem of a running system. This module is the practitioner reference: what to capture, what each artefact tells you, and how container and Kubernetes workloads change the picture.

Why this module exists. Linux IR responders often default to “tar up /var/log and call it done.” Modern Linux estates — especially in Indian cloud-native shops — have far richer artefacts available if you know to capture them. This module is the structured walkthrough.

The first-response capture — what to grab in 5 minutes

If you have shell access to a suspected-compromised Linux host and only minutes before something forces a reboot, capture this in order:

# Volatile state — captures running picture
ps auxf > /evidence/ps.txt
ss -tnpoa > /evidence/connections.txt
lsof +D / 2>/dev/null > /evidence/openfiles.txt
last -F > /evidence/last.txt
who -a > /evidence/who.txt
mount > /evidence/mount.txt
cat /proc/modules > /evidence/modules.txt
crontab -l > /evidence/cron-root.txt
for u in $(cut -d: -f1 /etc/passwd); do crontab -u $u -l 2>/dev/null; done > /evidence/cron-all.txt

# Bash history — every account
cp /home/*/.bash_history /evidence/ 2>/dev/null
cp /root/.bash_history /evidence/ 2>/dev/null

# Recent files (modified in last 24h)
find / -mtime -1 -type f 2>/dev/null > /evidence/modified-24h.txt

# Network state — if persistent attacker is suspected
iptables-save > /evidence/iptables.txt
nft list ruleset > /evidence/nftables.txt

# Then take a memory image (Module 3)
# Then take a disk image / snapshot (Module 2)

Auditd — the rich audit framework you should be running

Auditd is Linux’s kernel-level audit framework. Rules tell it what to log; events go to /var/log/audit/audit.log. The right baseline rule set (cribbed from Florian Roth’s auditd template) catches credential reads, command execution, network admin tools, and key system file modifications.

# Sample rules — drop in /etc/audit/rules.d/forensics.rules
# Track all execve calls (every command)
-a always,exit -F arch=b64 -S execve -k command-exec

# Track sudo
-w /etc/sudoers -p wa -k sudoers-change
-w /var/log/sudo.log -p wa -k sudo-log

# Track passwd/shadow changes
-w /etc/passwd -p wa -k user-modify
-w /etc/shadow -p wa -k passwd-change

# Track ssh key file changes
-w /root/.ssh/ -p wa -k ssh-key-root
-w /home/ -p wa -k ssh-key-user

# Reload
sudo augenrules --load

# Query
ausearch -k command-exec --start today | aureport -i

Journalctl — the systemd journal

On systemd-based distros (almost everything modern), journalctl is the unified log query interface. Key queries:

# All entries from a specific service
journalctl -u sshd.service --since "2026-05-13 00:00:00"

# Boot history (each boot is identified)
journalctl --list-boots

# Filter by priority — errors and above
journalctl -p err --since "1 day ago"

# Persistent storage — by default journal is RAM-only
# Check /etc/systemd/journald.conf — Storage=persistent is what you want for IR

If Storage=auto is set and /var/log/journal/ does not exist, journal is volatile and is lost on reboot. Fix this baseline on every server before you need IR.

Container forensics — the new surface

Containers complicate Linux IR in three ways:

  1. Filesystem is layered. The running container’s / is an overlay of immutable layers + a writable top layer. Forensic copy means capturing the writable layer separately, then mapping back to the image SHA.
  2. Process namespace is isolated. The host sees container processes; the container sees only its own. Always do forensics from the host’s perspective for completeness.
  3. Containers are usually ephemeral. By the time you investigate, the container is gone. Forwarding container logs to a central SIEM is the only practical preservation.
# Capture a running container's writable layer
docker commit suspect-container forensic-snapshot:latest
docker save forensic-snapshot:latest | gzip > /evidence/container.tar.gz

# Or from containerd directly
ctr -n k8s.io snapshots ls
ctr -n k8s.io snapshots tree <container-id>

# Kubernetes: capture pod logs + container layer + describe output
kubectl logs suspect-pod --all-containers --previous > /evidence/pod-logs.txt
kubectl describe pod suspect-pod > /evidence/pod-describe.txt
kubectl get pod suspect-pod -o yaml > /evidence/pod-spec.yaml

eBPF — runtime visibility for the modern stack

For ongoing detection (not post-hoc IR), eBPF probes give Linux equivalents to Sysmon: process creation with parent PID + command line, file opens, network connections, all collected at kernel level with minimal overhead. Falco, Tetragon, and Tracee are the canonical tools. The right time to deploy is before you need IR; running them only after a compromise wastes the killer feature (the timeline before now).

Key takeaways

  • First-response: capture ps/ss/lsof/last/cron + bash history + recent files, then memory, then disk.
  • Auditd with a sensible rule set captures execve, sudo, and credential file changes.
  • journalctl is the unified systemd log; ensure persistent storage is enabled.
  • Container forensics: capture the writable layer, log forward early — containers are ephemeral.
  • eBPF tools (Falco, Tetragon, Tracee) are the runtime visibility upgrade.
Worried about your exposure?

Get a free attack-surface review

We check what an attacker would see about your business — leaked credentials, exposed services, dark-web mentions. 30 minutes, no obligation.

Book exposure review Replies in 4 working hrs · India-only · Senior consultants