defencia/knowledge/linux
Intro · Packages · Terminal · DFIR toolkit

Linux

If you have never used Linux, getting started takes a little work — but it is free, light on resources, and a multitool for DFIR once you learn the terminal. This page takes you from first principles to the handful of commands that do most of the heavy lifting in an investigation.

Free / OSSDebian-based

Intro to Linux

If you have not used Linux, getting started takes a little extra work — but there is plenty of help online and most things are easier than they look. Linux is free and open source, needs fewer resources than Windows, and can breathe life into an old PC.

Strictly speaking, "Linux" is just the kernel — the core that talks to your hardware. What you actually install is a distribution (a "distro"): the kernel plus a desktop, a package manager and a curated set of software, assembled by a community or company. That is why Ubuntu, Debian and Mint can all be "Linux" yet look and feel different.

Why Linux matters for DFIR

For a digital investigator, Linux is not just a cheaper Windows. It changes how you can work with evidence:

Read-only by design

You can mount a disk image or evidence drive read-only, so the act of looking never alters the source. Preserving integrity is the whole game in forensics.

No hidden activity

No registry churn, no background telemetry rewriting timestamps. What runs, runs because you told it to — which keeps your analysis machine predictable.

Scriptable everything

Every tool is text-in, text-out and chainable. One line can carve, filter, sort and hash thousands of files. Repeatable steps mean defensible results.

The tools live here

The Sleuth Kit, Volatility, YARA, Wireshark, plaso and most open-source DFIR tooling are first-class citizens on Linux, often packaged and ready to install.

DFIR-focused distros

You can do forensics on any distro, but several are pre-built with the tooling already in place:

REMnux

A reverse-engineering and malware-analysis toolkit on Ubuntu. The go-to for examining a suspicious sample safely.malware analysis

SIFT Workstation

SANS' free incident-response and forensics distro — disk, memory and timeline tooling in one place.IR + forensics

Tsurugi Linux

A DFIR-oriented distro with a strong focus on acquisition and analysis, plus OSINT tooling.acquisition

Kali Linux

Best known for offensive security, but its forensics mode and packaged tools make it useful on the blue-team side too.broad toolkit

If you are just starting out, install Ubuntu or Linux Mint in a virtual machine first. It is the gentlest on-ramp, and you can move to a specialised distro once the terminal feels natural.

Packages

Linux ships many distributions differing in look and installed software (called packages). Package management differs per distro — RPM (Red Hat Package Manager) and DPKG (Debian) are the two main families. The course uses Debian-based Linux (Ubuntu, Linux Mint, Debian, REMnux).

A package is a bundle of software plus a description of everything it needs to run (its dependencies). A package manager installs that bundle, pulls in the dependencies automatically, and keeps track of what is on the system so you can update or remove it cleanly. No hunting for installers, no leftover files — this is one of the quiet pleasures of Linux.

The two main families
FamilyUsed byLow-level toolHigh-level tool
DPKG (Debian)Debian, Ubuntu, Mint, REMnuxdpkgapt
RPM (Red Hat)Fedora, RHEL, CentOS, Rockyrpmdnf / yum

On the Debian-based systems used here, apt is the command you will reach for daily. The typical workflow:

$ sudo apt update          # refresh the list of available packages
$ sudo apt upgrade         # install updates for what you already have
$ sudo apt install yara    # install a package (and its dependencies)
$ apt search sleuthkit     # find a package by keyword
$ apt show sleuthkit       # read the description before installing
$ sudo apt remove yara     # uninstall, keeping config files
$ sudo apt purge yara      # uninstall and remove config too
The everyday apt cycle. update refreshes the catalogue; upgrade applies it.
Order matters: always run apt update before apt install or upgrade. Without it, you are installing from a stale catalogue and may pull an old version or fail to find a package at all.
DFIR tools worth installing

A starter set you will likely want on an analysis machine:

$ sudo apt install sleuthkit yara clamav-daemon \
      wireshark tshark binwalk foremost exiftool \
      net-tools curl jq
The Sleuth Kit (disk forensics), YARA (pattern matching), ClamAV (AV scanning), Wireshark/tshark (network), binwalk/foremost (carving), exiftool (metadata), plus handy utilities.

The terminal

The terminal — the Command Line Interface (CLI) — is where Linux shows its power, and for many it is a learning curve: new commands, flags and ways of working in a text box.

lablo@linuxserver:~$ sudo apt-get update
A typical terminal prompt and an update command.

That prompt tells you more than it looks. Read it left to right:

PartMeaning
labloThe user you are logged in as.
linuxserverThe hostname of the machine.
~Your current directory (~ is your home folder).
$A normal user prompt. A # here means you are root — full power, full risk.
Anatomy of a command

Almost every command follows the same shape: the command, some options (flags), and one or more arguments.

$ ls -lah /var/log
  │   │    └── argument  (what to act on)
  │   └─────── options   (how to behave: long, all, human-readable)
  └─────────── command   (what to run)
Short flags combine: -lah is the same as -l -a -h.
sudo and permissions

Linux protects system areas behind the root account. sudo ("superuser do") runs a single command with elevated rights — far safer than logging in as root permanently. If a command fails with Permission denied, that is usually the system telling you to think before you reach for sudo.

Pipes and redirection — the real power

This is the idea that makes Linux a multitool. Every command produces text, and you can feed one command's output straight into the next. Small, single-purpose tools combine into something far larger than any one of them.

OperatorDoesExample
|Pipe — send output of one command into the nextcat auth.log | grep Failed
>Redirect output to a file (overwrites)... > results.txt
>>Append output to a file... >> results.txt
2>Redirect errors separatelyfind / ... 2>/dev/null
$ cat access.log | grep "POST" | awk '{print $1}' | sort | uniq -c | sort -rn
Read a log, keep POST requests, pull the IP, then count and rank them — five tiny tools, one investigative answer.

The filesystem

Unlike Windows' drive letters, Linux has a single tree starting at / (the root). Knowing where things live is half of any investigation — logs, configs and running-process data all have a home.

PathWhat lives there — and why you care
/etcSystem and service configuration. Persistence and tampering often show up here.
/var/logLogs. Your first stop in almost every investigation — auth, syslog, web server, etc.
/homeUser data and dotfiles. Shell history, SSH keys, downloads.
/tmpTemporary files. A common staging ground for dropped payloads.
/procA live view of running processes and the kernel — not real files on disk.
/bin /usr/binExecutables. Compare against a known-good baseline to spot trojanised binaries.
/rootThe root user's home directory.

Navigation is quick once the verbs are muscle memory:

$ pwd                 # where am I?
$ ls -lah             # list everything, with detail and sizes
$ cd /var/log         # change directory
$ cd ..               # up one level
$ cd ~                # back to home
Tab-completion saves enormous time — type a few letters and press Tab.

Core commands for DFIR

A small set of commands covers most investigative needs. Learn these and you can read logs, find files, follow processes and verify evidence — the everyday motions of an examiner.

Reading files
CommandUse
cat fileDump a whole file to the screen. Fine for small files.
less filePage through a large file without loading it all. / searches, q quits.
head -n 50 fileFirst 50 lines.
tail -n 50 fileLast 50 lines.
tail -f fileFollow a log live as new lines arrive — invaluable while reproducing an event.
Finding files

find walks the filesystem and filters on almost any property — name, age, size, permissions. It is the workhorse for locating artifacts in a mounted image.

$ find / -name "*.php" -mtime -1 2>/dev/null
$ find /tmp -perm -4000 -type f          # SUID files — classic privesc check
$ find /home -name "id_rsa" 2>/dev/null  # SSH private keys left behind
$ find / -newermt "2026-06-23" -type f 2>/dev/null
PHP files changed in the last day; SUID binaries; stray private keys; everything modified after a given date. 2>/dev/null hides the "permission denied" noise.
Processes and network
$ ps aux --sort=-%cpu        # all processes, hungriest first
$ ss -tulpn                  # listening ports + owning process
$ lsof -p 1337               # files and sockets a process has open
$ ss -tn state established   # active connections right now
What is running, what is listening, and what it is talking to — the live-triage trio.
For the full searchable command reference used across the Defencia infrastructure — services, firewall, Docker and more — see the Linux commands cheatsheet.

Log analysis with text tools

Logs are just text, and Linux is exceptional at text. Four small tools — grep, awk, cut, sort/uniq — answer most "who, what, how many" questions you will ask of a log.

ToolOne-line role
grepFind lines matching a pattern. The single most important text tool — see the full cheatsheet.
awkTreat each line as columns; print, compute or filter by field.
cutSlice out fixed columns by delimiter — lighter than awk for simple jobs.
sort / uniqOrder lines and collapse or count duplicates.
wc -lCount lines — how many hits, how many events.
# Top 10 IPs hitting a web server
$ awk '{print $1}' access.log | sort | uniq -c | sort -rn | head

# Failed SSH logins, with the offending IP
$ grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn

# How many 404s today
$ grep " 404 " access.log | wc -l

# Pull the 4th column (a field) from a colon-delimited file
$ cut -d: -f4 /etc/passwd
Each pipeline reads like a sentence: extract a field, sort it, count it, rank it. This is the core rhythm of log triage on Linux.
Tip: build pipelines incrementally. Run the first command, look at the output, then add the next | stage. You learn far more by watching the data narrow at each step than by typing the whole line at once.

Artifact triage

When you have an unknown file — a suspicious download, a carved fragment, a sample from an alert — a few commands tell you what it is and let you record it defensibly before you do anything else.

CommandAnswers
file sample.binWhat type is this, really? Identifies by content (magic bytes), not by the extension someone gave it.
stat sample.binModify / access / change timestamps and permissions — the MAC times that anchor a timeline.
strings -n 8 sample.binPrintable text inside a binary — URLs, IPs, commands, ransom notes. Often the fastest first clue.
sha256sum sample.binA cryptographic hash to record the file and look it up against VirusTotal or a known-bad list.
xxd sample.bin | headA hex + ASCII view of the first bytes — read the magic header directly.
$ file invoice.pdf.exe
invoice.pdf.exe: PE32 executable (GUI) Intel 80386, for MS Windows

$ strings -n 8 invoice.pdf.exe | grep -iE "http|\.exe|cmd|powershell"
$ sha256sum invoice.pdf.exe
$ stat invoice.pdf.exe
A "PDF" that file reports as a Windows executable is the whole story. strings piped into grep then surfaces the indicators worth chasing.
Handle unknown samples in isolation. Inspect suspicious files inside a disposable VM or sandbox (REMnux, Kasm), never on your own working machine. file and strings are passive, but the moment you risk execution, containment matters.
Verifying evidence integrity

Hashing is not only for malware — it is how you prove a copy is identical to the source. Hash before and after any handling and the values must match.

$ sha256sum evidence.img > evidence.img.sha256   # record at acquisition
$ sha256sum -c evidence.img.sha256               # verify later: OK or FAILED
A matching hash is your defensible proof that the evidence was not altered.

Where to go next

This page is a foundation. Two companion references go deeper.

grep — the full cheatsheet

Regex basics, every useful flag, and DFIR-focused examples: hunting IOCs, extracting IPs and emails, searching across a mounted image.Open grep cheatsheet →

Linux commands cheatsheet

A searchable reference of the commands used across the Defencia infrastructure — services, networking, firewall, Docker and DFIR triage.Open command reference →