Record and Replay Linux Terminal Sessions with script & scriptreplay
Learn how to capture every command and its output in a Linux terminal using the script command, store it as a text session file, and later replay the exact sequence with scriptreplay, including useful options for teaching, auditing, and demonstrations.
The script utility records all input and output of a terminal session, saving it to a plain‑text file that can be opened with any editor. This makes it ideal for preserving command‑line demonstrations, creating tutorials, or auditing activity.
After recording, the scriptreplay command can replay the session, reproducing the timing and output as if the commands were being executed live, which is helpful for teaching or sharing workflows.
Typical usage:
script -t 2> linuxidc.log -a linuxidc.com.sessionRun the above command, perform the desired terminal actions, then type exit to stop recording. The session data is stored in linuxidc.com.session and timing information in linuxidc.log.
To replay: scriptreplay linuxidc.log linuxidc.com.session The terminal will play back the recorded commands and output, allowing others to view exactly what was done.
Useful script options:
-a Append new output to an existing session file.
-c Execute a specific command instead of starting an interactive shell.
-r Return the exit status of the child process.
-f Show output on the screen while also writing to the log file (useful for live demos).
-q Run in quiet mode, suppressing start/stop messages.
-t Record timing data for later replay.
-V Display the version of script and exit.
-h Show help information and exit.
These options enable flexible recording scenarios, such as appending to logs, silent operation, or capturing precise timing for accurate replay.
Example screenshot of a recorded session and the resulting replay can be seen in the images below.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
