T.03 · Terminal Fundamentals

Session Recording

Capture every keystroke and every byte of output from a terminal session. Replay it. Print it. Turn it in.

Almost every lab in this course ends with a question like: "submit a transcript of your work showing the commands you ran and the output you got." The traditional answers — copy-pasting into a Word document, taking screenshots, retyping from memory — are slow and error-prone. The professional answer is to record the session.

This page covers three tools that record terminal sessions: script (built into every Linux system), asciinema (modern, web-shareable, requires install), and ttyrec (the historical predecessor that's still worth knowing). Plus the practical bit: how to print or share the recording when the lab is done.

Why record a session

Tool 1 — script: the built-in

script — record any session, no install

Ships with: every Linux, every macOS, since the 1980s
No install needed Plain text output

script is part of util-linux — the same package that gives you mount and su. It's been on every Unix system since the early 1980s. You will never be on a Linux box that doesn't have it.

Start a recording

$ script ~/lab3-session.txt Script started, output log file is '/home/alice/lab3-session.txt'.

From this point on, everything you type and everything you see is captured to that file. Run your lab work normally.

Stop the recording

$ exit # or press Ctrl+D Script done.

You can also run a single command and capture just that:

$ script -c "nmap -sV scanme.nmap.org" ~/scan-output.txt

Read the recording

The output file is plain text with embedded ANSI color codes. Open it with any text editor or pager:

$ cat ~/lab3-session.txt # raw text (colors will look like garbage) $ less -R ~/lab3-session.txt # -R shows colors correctly

Record with timing — for replay

To replay the session at the speed you typed it, capture timing data too:

$ script --timing=lab3.tim ~/lab3-session.txt # ...do the lab work, then exit... $ scriptreplay --timing=lab3.tim ~/lab3-session.txt # The terminal "replays" the session: same characters appear at the same pace you typed.

This is the magic trick. scriptreplay turns your recording into a movie. Pair it with --divisor 4 to play back 4x faster, useful when you ran a long-running command and want the highlights.

Practical day-of-class workflow

$ script --timing=~/cyberlab/$(date +%F).tim ~/cyberlab/$(date +%F).log # That gives you per-day files: 2026-06-05.log + 2026-06-05.tim

At the end of the day, both files are sitting in ~/cyberlab/, dated. To submit: attach the .log file (the transcript). To replay later: scriptreplay with both files.

Tool 2 — asciinema: the modern share-friendly option

asciinema — record & share to the web

Open source · asciinema.org
apt install asciinema JSON / SVG export

Where script produces a text file, asciinema produces a small JSON file that captures every keystroke with precise timing. The same recording can be replayed in a terminal, embedded in a web page, or exported as an animated SVG — without any video file or screen capture.

Install

$ sudo apt install asciinema # Debian / Ubuntu $ sudo dnf install asciinema # Fedora / RHEL / Rocky $ brew install asciinema # macOS $ pipx install asciinema # any system with Python

Record & play locally

$ asciinema rec lab3.cast asciinema: recording asciicast to lab3.cast asciinema: press <ctrl-d> or type "exit" when you're done # ...do your work... $ exit asciinema: recording finished $ asciinema play lab3.cast # The terminal replays the session at the speed you typed. $ asciinema play -i 2 lab3.cast # -i 2 = cap idle time to 2 seconds (skips long pauses)

Upload & share

$ asciinema upload lab3.cast View the recording at: https://asciinema.org/a/abc123xyz

The recording is hosted publicly (or unlisted) on asciinema.org. You get a URL you can paste into a lab report, an issue, a doc — the viewer plays the recording inline in any browser. This is the modern equivalent of "screenshot the terminal," except the viewer can scrub the timeline and copy text out of the playback.

Export as SVG (animated, embeddable, printable)

$ npm install -g svg-term-cli $ cat lab3.cast | svg-term --out lab3.svg

The .svg file animates in any browser, embeds in markdown, and prints to PDF cleanly. Great for documentation that has to live in a doc system that doesn't render asciinema URLs.

Privacy tip. By default uploaded recordings are public. Pass --quiet to skip the upload prompt, or upload as unlisted with the web UI. For sensitive lab work, prefer script + local file submission — nothing leaves your machine.

Tool 3 — ttyrec: the historical option

ttyrec — the classic Unix tty recorder

Released 2000 · still maintained · minimalist
apt install ttyrec

ttyrec predates asciinema by 13 years and is still installed on many older Linux systems. It records to a binary format and plays back with ttyplay. Less polished than asciinema; smaller files; still useful when you're on a stripped-down system where you can install one small package.

$ ttyrec lab3.ttyrec # ...work... $ exit $ ttyplay lab3.ttyrec # at original speed $ ttyplay -s 5 lab3.ttyrec # 5x speed $ ttyplay -n lab3.ttyrec # no delays (instant playback)

Most modern courses use script or asciinema. ttyrec is mentioned here mainly so you recognize it when you encounter a .ttyrec file in the wild.

Pick one — the comparison

Which tool fits which job

 scriptasciinemattyrec
Pre-installedYes (everywhere)No (apt/dnf/brew)No
Output is human-readableYes (plain text)JSONBinary
Web-shareable URLNoYes (asciinema.org)No
Embeddable in browserNoYes (player + SVG)No
Timing preserved for replayYes (with --timing)Yes (built in)Yes
File size for 10-min session~50 KB~20 KB~30 KB
Easy to grep / search throughYes (text)Partial (JSON has the text inside)No

For this course: use script by default. It's everywhere, the output is plain text you can submit directly, and it requires zero setup. Reach for asciinema when you want a polished playback experience or want to share a recording with a URL.

Turning a recording into a deliverable

Once you have the recording, the lab usually wants something you can submit through the LMS. Three patterns cover essentially every case:

Pattern 1: submit the raw transcript

For script output, the file is already plain text. Attach the .txt file to your submission.

Pattern 2: print to PDF

If the LMS wants a single document, convert the transcript to PDF. Two easy ways:

# Method A: enscript (preserves layout, fits to page) $ enscript -B -f "Courier8" --word-wrap lab3.txt -o - | ps2pdf - lab3.pdf # Method B: pandoc (cleaner-looking output) $ pandoc lab3.txt -o lab3.pdf -V "monofont=Courier"

Pattern 3: paste a clean copy into a writeup

For partial transcripts (just the interesting commands), strip the ANSI color codes and paste into your writeup document:

$ cat lab3.txt | sed 's/\x1b\[[0-9;]*[mGK]//g' > lab3-clean.txt

That sed incantation removes ANSI escape sequences. The result is plain text, ready to paste into a markdown file, a Word doc, or a Brightspace text field.

The end-of-class habit worth building. Start each lab session with script ~/cyberlab/$(date +%F).log. Do your work. At the end of class, you have a dated transcript of everything. Pull out the commands you want to submit, attach the file as appendix evidence, and move on with your day. The labs that ask "show me what you typed" become five minutes of work instead of an hour of reconstruction.
The point

Recording your terminal session takes one extra command at the start of the lab and one at the end. The payoff is enormous: exact transcripts, replayable on demand, printable as PDFs, shareable as URLs. Every lab in this course that asks for a transcript gets easier the day you start using one of these tools.

Use script by default. Add asciinema when you want web-shareable playback. Both belong in the muscle memory of any Linux user serious about their work.

References

Formatted in APA 7. Alphabetized by first author's last name.

  1. asciinema. (n.d.). asciinema: Record and share your terminal sessions. https://asciinema.org/
  2. Kerrisk, M. (n.d.-a). script(1): Linux manual page. Linux man-pages project. https://man7.org/linux/man-pages/man1/script.1.html
  3. Kerrisk, M. (n.d.-b). scriptreplay(1): Linux manual page. Linux man-pages project. https://man7.org/linux/man-pages/man1/scriptreplay.1.html
  4. Marc'O. (n.d.). ttyrec: A tty recorder. https://0xcc.net/ttyrec/
  5. Sitnikovski, M. (n.d.). svg-term-cli: Share terminal sessions via animated SVG [Source code]. GitHub. https://github.com/marionebl/svg-term-cli