UnixDroid

Lesson 6 of 8 · 8 min

Linux artifacts & spotting cleared logs

Where Linux records logins, commands and persistence, and how to catch an attacker who tried to erase it all.

Most servers on the internet run Linux, so most server breaches end with a Linux investigation. The good news: Linux keeps plain-text records of almost everything.

Where to look

ArtifactLocationWhat it tells you
Auth log/var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL)SSH logins, failed passwords, sudo use
Login history/var/log/wtmp (read with last), /var/log/btmp (lastb)Who logged in, from where, for how long
Shell history~/.bash_history, /root/.bash_historyCommands a user typed
Scheduled tasks/etc/crontab, /etc/cron.d/, /var/spool/cron/crontabs/Jobs that run automatically, a favourite persistence trick
Services/etc/systemd/system/Custom services that start at boot
SSH keys~/.ssh/authorized_keysKeys that allow password-less login
Temp folders/tmp, /var/tmp, /dev/shmWhere attackers drop their tools

Investigating a brute-force attack

Who tried to guess passwords, and how many times?

grep "Failed password" /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -nr | head

Did any of them get in?

grep "Accepted" /var/log/auth.log
last -i | head -20

An IP that fails 500 times and then appears in an "Accepted" line is your attacker's way in.

Hunting persistence

cat /etc/crontab; ls -la /etc/cron.d/
sudo ls -la /var/spool/cron/crontabs/
sudo cat /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys
ls -lat /etc/systemd/system/ | head
sudo find / -xdev -type f -newermt "2026-11-01" 2>/dev/null | head -50

The last command lists files changed since a given date. Swap in the date your incident started.

Spotting cleared logs and anti-forensics

Attackers try to erase their tracks, but erasing leaves its own clues:

Attacker trickWhat you'll notice
Emptied a log with > /var/log/auth.logFile is 0 bytes or suspiciously small, with a recent modify time
Disabled history with unset HISTFILE or ln -sf /dev/null ~/.bash_history.bash_history is missing, empty or a link to /dev/null
Deleted specific linesGaps in timestamps: hours with no entries on a busy server
Faked file times with touchThe change time (ctime) is newer than the modify time (mtime)

Check timestamps with stat:

stat /var/log/auth.log
ls -la ~/.bash_history

touch can fake the modify time, but not the change time. ctime updates whenever a file's metadata changes, including when someone runs touch.

Tip: If logs were also sent to a SIEM or a remote syslog server, compare the two. Attackers clear the local copy but rarely reach the remote one.

Don't forget the journal

On systemd systems, the journal keeps its own copy of many events, and some newer distributions log only there:

journalctl _COMM=sshd --since "2026-11-20" --until "2026-11-22"

On Linux, the question is rarely "is there evidence?" It's "which of the twelve places did the attacker forget to clean?"

Try it yourself
  1. On your Kali VM, start SSH: sudo systemctl start ssh
  2. Run ssh fakeuser@127.0.0.1 and enter a wrong password three times. Then log in once with your real account.
  3. Find all four events with sudo journalctl _COMM=sshd (or grep sshd /var/log/auth.log if that file exists).
  4. Run last -i and stat ~/.bash_history. Write down your login time and the history file's last modify time.
No Linux machine? Practise in the free online terminal

Quick check

On Linux, which timestamp can the touch command NOT fake: mtime or ctime?

Need a hint?

It updates whenever the metadata changes.

Finished this lesson?

Done lessons keep your daily streak going 🔥

0 day streak

0 lessons done

best 0 days

Log in to keep your streak on every device →