How to Record Your Terminal Session on Linux by using ttyrec

Recording a terminal session may be important in helping someone learn a process, sharing information in an understandable way, and also presenting a series of commands in a proper manner. Whatever the purpose, there are many times when copy-pasting text from the terminal won’t be very helpful while capturing a video of the process is quite far-fetched and may not be always possible.

In this quick guide, we will take a look at the easiest way to record and share a terminal session in .gif format. If you just want to record your terminal sessions and be able to play the recording in your terminal, or share them with people who will use a terminal for playback, then the only tool that you’ll need is called “ttyrec”. Ubuntu users may install it by inserting the following command on a terminal:

sudo apt-get install ttyrec 

If you want to produce a .gif file from the recording and be able to share it with people who don’t use the terminal, publish it on websites, or simply keep a .gif handy for when you’ll need it instead of written commands, you will have to install two additional packages. The first one is “imagemagick” which you can install with:

sudo apt-get install imagemagick 

And the second one is “tty2gif” which can be downloaded from here. The latter has a dependency that can be satisfied with:

sudo apt-get install python-opster 

To start capturing the terminal session, all you need to do is simply start with “ttyrec” + enter. This will launch the real-time recording tool which will run in the background until we enter “exit” or we press “Ctrl+D”. By default, ttyrec creates a file named “ttyrecord” on the destination of the terminal session which by default is “Home”.

Playing the file is as simple as opening a terminal on the destination of the “ttyrecord” file and using the “ttyplay” command followed by the name of the recording