How to Record Every Terminal Session with Linux’s script Command
Learn how the Linux script command can capture all terminal activity, how to start, stop, and customize recordings, and why it’s useful for collaboration, auditing, and automated logging in shared or remote environments.
When working in a terminal or console you may want to record everything that happens for later review, auditing, or sharing with teammates. The Linux script command creates a typescript file that logs all input and output of the session.
What is script
script is a utility that records everything displayed on the terminal into a text file, allowing you to replay or examine the session later.
How to use
Start a recording with the default file name:
pungki@dev-machine:~$ script
Script started, file is typescriptSpecify a custom file name: pungki@dev-machine:~$ script myfile When the prompt returns, everything typed and output will be saved to the file.
Why use script
Typical scenarios include:
Collaborating with colleagues : Record a session to a file (e.g., script collaborate) and share it so another engineer can review or append their work using the -a option.
Auditing remote users : Add script to a shell startup file (e.g., ~/.profile) so it runs automatically on login, logging all activity to a central location.
Example of adding script to ~/.profile for silent, append‑only logging:
# run the script command to record everything
# use -q for quiet and -a to append
/usr/bin/script -qa /usr/local/script/log_record_scriptThe -q option runs script in quiet mode so the user does not see a notification, while -a appends to the existing log instead of overwriting it.
Stopping the recording
Terminate the session by pressing Ctrl+D or typing exit . The log file size will increase after the session ends.
Further information
For more details, view the manual pages with man script or script -h.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
