Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Building a timeline from file system times

After this lesson: I can build a timeline from file system times and read what happened in order.

60 min lesson10 commandsIncident response and forensics lab: investigate a compromised server in your browser

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Fifteen minutes on a Wednesday night

The client list went missing some time on 14 October. Nobody remembers what they did that evening, but the disk does: every file carries times for when it was changed, read and created.

Put those times from every file in one list, in order, and the evening tells itself.

By the end of this lesson

Note

I can build a timeline from file system times and read what happened in order.

Key words

WordWhat it meansExample
Timelineevents from many sources sorted by time
MACBmodified, accessed, changed and born times
Body fileone line of times per file, for mactime
Time zonethe offset of local time from UTCEurope/London
Super timelinefile times and other records in one timeline

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

The one rule

Important

Build timelines only from your own lab copy. A real person's file times show what they did and when. Reading them needs written permission or a lawful order, under the Computer Misuse Act 1990. J. Morgan and the firm are made up.

The disk from lesson 1

This lesson reads suspect.img, the made-up firm's disk that lesson 1 made in ~/forensics. If the Run below says it is missing, do lesson 1's first Runs on this VM, then come back.

Move in and find the disk

Command
cd ~/forensics && ls -l suspect.img

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Every file has four times

ext4 keeps four times in each inode, called MACB. Modified is when the content last changed. Accessed is when it was last read. Changed is when the inode itself changed, such as its owner. Born is when it was created.

Read them for the client list on the laptop, inode 22.

Read the client list's four times

Command
istat -o 67584 suspect.img 22 | grep -A5 "Inode Times"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Try it: sort one file's times

Code: python
times = {"m": "2026-10-02 16:20:44", "a": "2026-10-14 21:44:02", "c": "2026-10-02 16:20:44", "b": "2026-09-01 09:10:00"}
for letter, when in sorted(times.items(), key=lambda pair: pair[1]):
    print(when, letter)
# Change "c" to "2026-10-14 21:47:30" (a new owner, say), then press Run.

Make a free account to save your work and track your progress.

A body file, then mactime

fls -m writes a body file: one line per file holding its four times. Do it for both partitions into one file, then mactime sorts every time into a timeline, one line per event.

The letters m, a, c and b show which times fell at that moment. -d asks for commas between columns.

Write the laptop's times

Command
fls -r -m /laptop -o 67584 suspect.img > body.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Add the stick's times, read in UK time

Command
fls -r -m /stick -z Europe/London -o 2048 suspect.img >> body.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Sort 14 October into a timeline

Command
mactime -b body.txt -d -z UTC 2026-10-14 2>/dev/null

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

FAT keeps local time

ext4 stores times in UTC. FAT stores the laptop's local time zone, with no note of which it was. In October the UK is on BST, an hour ahead.

That is why the stick was read with -z Europe/London. Leave it out and the copy appears an hour after the history says it happened.

Read the stick's CSV without a zone

Command
fls -m /stick -o 2048 suspect.img | mactime -d -z UTC 2>/dev/null | grep LIENTS

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think every file time is in UTC. ext4 and NTFS store UTC, but FAT stores local time with no zone at all. Find out the device's zone first, or two sources in one timeline sit an hour apart.

Add the history to the same timeline

A super timeline adds other records to the file times. Bash wrote each command's time above it in .bash_history, inode 27, in seconds since 1970.

The script turns those into body file lines, so mactime sorts the commands among the files. Tools such as Plaso do this for hundreds of record types.

Recover the bash history by its inode

Command
icat -o 67584 suspect.img 27 > history.txt && head -4 history.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the history reader

Command
printf '%s\n' 'import sys' 'when = None' 'for line in open(sys.argv[1]):' '    line = line.rstrip(chr(10))' '    if line.startswith("#") and line[1:].isdigit():' '        when = line[1:]' '    elif when:' '        print("|".join(["0", sys.argv[2] + ": " + line, "0", "history", "0", "0", "0", when, when, when, when]))' > history.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Add the commands to the body file

Command
python3 history.py history.txt jmorgan >> body.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Sort the evening, files and commands together

Command
mactime -b body.txt -d -z UTC 2026-10-14T21:30:00..2026-10-14T22:00:00 2>/dev/null

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Assignment: sort a body file

A body file line has eleven fields split by |: md5, name, inode, mode, uid, gid, size, then atime, mtime, ctime and crtime as seconds since 1970 (0 means unknown).

parse(line) returns a dictionary with "name", "inode" (an int), "size" (an int) and "times", a dictionary from "m", "a", "c" and "b" to the int times, leaving out any that are 0.

events(lines) returns a list of (time, letters, name), one per distinct time of each file, where letters is the four-character MACB string mactime prints (a dot for each time not at that moment). Sort by time, then name.

between(evts, first, last) keeps the events whose time is from first to last, both included.

Code: python
def parse(line):
    return {}

def events(lines):
    return []

def between(evts, first, last):
    return []

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.