Evidence is any data that helps explain what happened: logs, files, process lists, memory, disk images. It is easy to damage by accident, so decide what to save before you start fixing things.
Check first that you are authorised to collect it. Logs and files can contain personal data. If legal action is possible, ask your legal or security lead how they want it handled.
Most volatile first
Some data disappears quickly. RFC 3227 calls this the order of volatility: memory, network state and running processes go before disks, and disks go before archived backups.
$ ps -eo pid,ppid,user,lstart,cmd > /mnt/evidence/ps.txt
$ sudo ss -tunap > /mnt/evidence/sockets.txtWrite output to separate storage, not to the disk you are investigating, because new files can overwrite deleted data. Running any command changes the system a little, so note each one you run. Memory capture needs a dedicated tool that your team has tested in advance.
Copy logs and keep timestamps
$ sudo cp -a /var/log /mnt/evidence/var-log
$ sudo journalctl --utc -o short-iso > /mnt/evidence/journal.txtcp -a preserves modification times, ownership and permissions where the destination filesystem supports them. Be aware that log rotation can remove old entries, so copy early.
Work on copies. Opening and saving an original in an editor changes it.
Hash and record
A cryptographic hash is a fingerprint of a file's contents. If one byte changes, the hash changes.
$ cd /mnt/evidence
$ sha256sum ps.txt sockets.txt journal.txt > SHA256SUMS
$ sha256sum -c SHA256SUMS
ps.txt: OK
sockets.txt: OK
journal.txt: OKA matching hash shows the file is the same as when you hashed it. It does not show that the data was truthful before that. Store a copy of the hash list somewhere else, so someone cannot alter both together.
Keep a chain of custody log: what was collected, from which host, by whom, when (in UTC), where it is stored, and every handover. Limit who can read the evidence.
Try it
Make a folder in your home directory, copy a harmless text file into it with cp -a, and create SHA256SUMS. Run sha256sum -c SHA256SUMS. Change one character in the copy and check again to see it report FAILED. The files lab is a safe place to practise copying.
Check your understanding
Evidence Preservation
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.