Fundamentals 5 min read

How to Record Every Terminal Session with Linux’s script Command

Learn how to use the Linux script command to capture all terminal output, specify custom log files, employ options for silent or append mode, and automate recording via shell profiles for collaboration and remote session monitoring.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Record Every Terminal Session with Linux’s script Command

When working in a terminal or console you may want to record everything that happens for later review or auditing.

What is the script command

script

is a Linux utility that records all output printed to the terminal, saving it to a text file that can be replayed later.

Basic usage

Run script to start recording; by default it creates a file named typescript.

pungki@dev-machine:~$ script
Script started, file is typescript
pungki@dev-machine:~$

You can specify a target filename, for example script myfile.

Useful options

The -a option appends to an existing file, while -q runs the command silently so the user does not see a notification.

Typical scenarios

Collaboration

When working with colleagues you can record a session to a file, e.g., script collaborate, and share the file for review. Others can add their own work using script -a collaborate.

Monitoring remote users

To automatically record actions of anyone who logs into your system, add a line such as /usr/bin/script -qa /usr/local/script/log_record_script to your ~/.profile (or other shell startup file). The logs are stored under /usr/local/script/log.

Stopping the recording

Press Ctrl+D or type exit. Before exiting the file size may be 0 KB; after the session ends the file grows to contain the recorded output.

Further reading

Use man script or script -h to view the full manual and additional options.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxscriptterminal recording
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.