How to record and replay a terminal session on Linux

Suppose you are a go to person among your friends and family when it comes to Linux related questions. Someone asked you how to install and configure a tool, and you wanted to show the procedures. How would you do that if he or she is not in front of you? There could be various ways (e.g., by documenting and emailing the procedures, or explaining verbally over the phone, etc), but probably the most clearcut solution would be to demonstrate it yourself. If the demonstration only requires a terminal, then the best way would be use terminal screencast or terminal session recorder.

In this tutorial, I am going to demonstrate how to record and replay a terminal session on Linux.

There are several online services (e.g., or which allow you to record and share your terminal sessions on the web. However, if you want privacy, or want to archive the recordings locally, I would recommend TermRecord.

TermRecord is an open-source tool written in Python, which records a terminal session into a standalone HTML file. Since the HTML-formatted output file is self-contained, anyone can replay the captured terminal session using a web browser, which is cross-platform.

Install TermRecord on Linux

TermRecord is available as a Python package, so you can install the package with pip command.

First, install pip on your Linux system. Then, install TermRecord as follows.

$ sudo pip install TermRecord

Record a Terminal Session with TermRecord

Recording a terminal session with TermRecord is easy. Simply run the command below to start recording.

$ TermRecord -o /path/to/output_html

For example, to save the current terminal session in /tmp/session.html:

$ TermRecord -o /tmp/session.html

Then any subsequent commands that are typed from the terminal will be saved to the output HTML file. The output file will also store timing information, so that the whole terminal session can be replayed in the same speed as you are typing.

If you want to stop the recording, simply type "exit" and press ENTER.

If you open up the HTML output on a web browser, you can play, pause or restart the stored session. You can also adjust the replay speed, i.e., speed up or slow down the session replay as you like.

Here is a sample terminal screencast generated by TermRecord.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

12 thoughts on “How to record and replay a terminal session on Linux

  1. Run 'man script'. It has been around for ages. No need for the target user to wait to see how you finished the job after that bathroom break.

    • script/scriptreplay are useful tools too. But I'd say TermRecord is more user friendly and powerful than them. Using TermRecord, you can replay what you see in a terminal exactly as it is, and this includes terminal scrolling and ncurses-based terminal GUI. Also I like its cross-platform HTML-based output.

  2. This looks cool, and while I have not checked it out, I did notice it is written in Python2. It needs to support Python3. Not sure why something would be pushed these days and not have forward compatibility.

  3. Apollogies, fingers were faster than my brain. It did work but I had to change some of my security setup. Personal code. Not public yet.

  4. Nifty.

    This recording and replaying functionality is definitely useful in the education sector.

  5. Terminal sessions in a cloud sounds insane to me. This looks great for tutorials. If you want auditing of users shell actions you can install sudosh. Set is as a users default shell and you can replay their session from a root console.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *