#Why this matters
Linux hosts power web servers, cloud workloads, and network appliances, yet they lack a centralized Registry or Prefetch cache. Instead, evidence is distributed across plain-text and binary logs, per-user shell files, service definitions, and ext4 inode metadata.
Because intruders on Linux routinely clear /var/log/auth.log or unset shell history, responders must know how to query binary systemd journals offline, spot hidden persistence entries, and detect timestamp forgery using inode ctime values and Sleuth Kit timelines.
- Logsjournald, auth.log, wtmp/btmp
- Shell.bash_history and rc files
- Persistencesystemd, cron, authorized_keys
- Timelinestat and Sleuth Kit mactime
#System and authentication logs
Modern Linux distributions (Debian, Ubuntu, RHEL, AlmaLinux) run systemd-journald alongside or instead of traditional text logs in /var/log/. Knowing both formats prevents missed evidence when one log stream is rotated or truncated.
| Artifact | Path | What it records |
|---|---|---|
| Auth log | /var/log/auth.log or /var/log/secure |
SSH logins, sudo invocations, su, PAM failures |
| Journald store | /var/log/journal/<machine-id>/ |
Structured binary logs for kernel, systemd units, and services |
| Login records | /var/log/wtmp and /var/log/btmp |
Successful (last) and failed (lastb) login sessions |
| Web/app logs | /var/log/nginx/ or /var/log/apache2/ |
HTTP requests, source IPs, user agents, and status codes |
You can inspect a mounted forensic image's binary journal directly from an analysis workstation without booting the suspect system by passing -D (or --directory) and --utc to journalctl.
$ journalctl -D /mnt/evidence/var/log/journal --utc -u ssh.service --since "2025-10-18 01:00:00"
Oct 18 01:14:22 app01 sshd[1842]: Accepted publickey for deploy from 198.51.100.44 port 51204 ssh2
Oct 18 01:15:09 app01 sudo[1890]: deploy : TTY=pts/0 ; PWD=/home/deploy ; USER=root ; COMMAND=/usr/bin/systemctl daemon-reloadBinary login files should also be read offline with last -f /mnt/evidence/var/log/wtmp and lastb -f /mnt/evidence/var/log/btmp. If an attacker deleted auth.log but forgot wtmp or the binary journal, those entries still confirm source IP addresses and session durations.
#Shell history and session context
Interactive Bash sessions record commands in ~/.bash_history, usually capped by HISTSIZE and HISTFILESIZE. However, Bash normally holds commands in memory until the shell exits cleanly. If a session is killed, still open, or deliberately ended with kill -9 $$, recent commands never reach disk.
Attackers also use simple evasion tricks such as export HISTFILE=/dev/null, unset HISTFILE, or leading spaces when HISTCONTROL=ignorespace is set. Look for gaps in command context and corroborate with secondary user artifacts:
~/.lesshstand~/.viminfo(or~/.local/state/nvim/shada/), which record files viewed or edited.~/.ssh/known_hostsand~/.ssh/authorized_keys, which expose outbound lateral movement and inbound backdoor keys.- Shell startup scripts (
~/.bashrc,~/.profile) modified to alterPATHor run commands on login.
#Persistence mechanisms
When an intruder establishes persistence on Linux, they typically target locations executed automatically at boot, on a schedule, or upon user authentication:
- Systemd services and timers: Custom
.serviceor.timerfiles placed in/etc/systemd/system/override vendor units in/lib/systemd/system/. InspectExecStartlines and recently modified unit files. - Cron jobs: Check
/etc/crontab,/etc/cron.d/,/etc/cron.hourly/,/etc/cron.daily/, and per-user crontabs in/var/spool/cron/crontabs/(or/var/spool/cron/). - SSH authorized keys: An unexpected public key appended to
/root/.ssh/authorized_keysor a service account'sauthorized_keysgrants persistent remote access without passwords. - Dynamic linker hijacking: An entry in
/etc/ld.so.preloadforces every dynamically linked binary to load a specified shared library.
#Ext4 MACB timestamps and Sleuth Kit timelines
On ext4 filesystems, stat exposes four key timestamps for every file:
- Access (
atime): Last read time (often restricted byrelatimemount options). - Modify (
mtime): Last time the file's data content changed. - Change (
ctime): Last time the inode metadata (permissions, ownership, link count, or timestamps) changed. - Birth (
crtime): Original inode creation time recorded on ext4.
An attacker can forge atime and mtime using touch -d to disguise a newly dropped script as an old system file. However, user-space tools cannot set ctime or crtime backward on a normal mounted filesystem; altering mtime updates ctime to the current kernel clock.
$ stat /mnt/evidence/usr/local/bin/healthcheck.sh
File: /mnt/evidence/usr/local/bin/healthcheck.sh
Size: 642 Blocks: 8 IO Block: 4096 regular file
Access: 2021-04-02 10:00:00.000000000 +0000
Modify: 2021-04-02 10:00:00.000000000 +0000
Change: 2025-10-18 01:14:55.412890112 +0000
Birth: 2025-10-18 01:14:55.408112004 +0000Here, Modify reads 2021-04-02, but both Change and Birth expose the true creation and tampering time of 2025-10-18 01:14:55 UTC.
To reconstruct activity across the entire partition, including unallocated deleted files, extract a Sleuth Kit bodyfile with fls and sort it with mactime:
$ fls -r -m / /cases/app01/root.dd > /cases/app01/bodyfile.txt
$ mactime -b /cases/app01/bodyfile.txt -d -z UTC 2025-10-18 > /cases/app01/timeline.csv
$ head -n 5 /cases/app01/timeline.csv
Date,Size,Type,Mode,UID,GID,Meta,File Name
Sat Oct 18 2025 01:14:55,642,.c.b,-rwxr-xr-x,0,0,131402,/usr/local/bin/healthcheck.sh
Sat Oct 18 2025 01:15:02,318,m.cb,-rw-r--r--,0,0,131409,/etc/systemd/system/healthcheck.serviceThe Type flags (m Modify, a Access, c Change, b Birth) immediately show healthcheck.sh having only c and b at 01:14:55 (because m was backdated to 2021), followed seven seconds later by creation of /etc/systemd/system/healthcheck.service.
#Common mistakes and analyst pitfalls
- Contaminating live timestamps: Mounting a forensic image read-write or running interactive searches on a live host alters
atimeand overwrites shell history buffers. Always mount evidence images with-o ro,noexec,noload(or parse images directly with Sleuth Kit). - Relying on
ls -lalone:ls -lshowsmtimeby default, which is trivially spoofed withtouch. Always inspectctimeandBirthviastatormactime. - Ignoring local vs UTC differences:
mactime -ddefaults to the examiner workstation's timezone unless-z UTCis specified, causing off-by-hours errors when correlating against UTC logs. - Overlooking deleted files in unallocated space: Plain
statonly sees active files; runningfls -r -m /against the raw disk image includes deleted entries still referenced in unallocated inodes.
#Summary
- Linux evidence spans
systemd-journaldbinary logs, text logs (/var/log/auth.logorsecure), binary login records (wtmp/btmp), shell artifacts, and persistence directories. - Attackers can suppress
~/.bash_historyor altermtimewithtouch, so investigators rely onjournalctl -D, secondary artifacts likeauthorized_keys, and ext4ctime/Birthmetadata. - Sleuth Kit
flsandmactimecombine active and deleted inode timestamps into a single chronological timeline normalized to UTC.