in the How to record terminal operations on Linux
Recording a terminal operation can be an easy way to help others learn Linux , display a series of correct command-line operations, and share knowledge. For whatever purpose, copying and pasting text from a terminal needs to be repeated many times, and the process of recording video is cumbersome and sometimes cannot be recorded. In this article, brother Lian www.lampbrother.net will simply learn how to record and share a terminal session in GIF format.
Pre-Request
If you just want to be able to record your terminal session and be able to play back at the terminal or share it with others, you only need a software called:ttyrec . Ubuntu users can install by running this line of code:
sudo apt-get install Ttyrec
If you want to convert the generated video into a gif file so you can share it with people who don't use the terminal, you'll be able to post it to the website, or you just want to make a gif easy to use without having to write commands. Then you need to install an additional two packages. The first one is ImageMagick, which you can install with the following command:
sudo apt-get install ImageMagick
The second package is:tty2gif.py, access to its Project site download. This package requires the following dependencies to be installed :
sudo apt-get install Python-opster
Recording
To start recording terminal operations, all you need to do is type ttyprec and then enter. This command will run a real-time logging tool in the background. We can stop by typing exit or ctrl+d . Ttyrec creates a Ttyrecord file in the home directory by default .
Playback
It's very easy to play back this file. You only need to open the terminal and use the ttyplay command to open the ttyrecord file. ( In this example, we use Ttyrecord as the filename, of course, you can also change the file name you use )
You can then start playing the file. This video records all the actions, including your deletion, modification. This looks like a self-conscious terminal, but the process of executing this command is not just for the system to look at, but to show it to people better.
Note that the playback of this record is completely controllable and you can speed up the deceleration by clicking + or - or 0 and 1 Pause and resume playback.
Export as GIF
For convenience, we usually convert video recording to gif format, and this is very easy to do. Here's how:
Copy the previously downloaded tty2gif.py file to the same directory as the ttyprecord file (or the video file you named), then open the terminal in this directory and enter the command:
Python tty2gif.py typing Ttyrecord
If an error occurs, check to see if you have a python-opster package installed. If you still have an error, use the following command to exclude it.
sudo apt-get install Xdotool
Export windowid=$ (Xdotool getwindowfocus)
Then repeat this command for python tty2gif.py and you will see Some more gif files in the Ttyrecord directory .
The next step is to integrate all the gif files and pack them into a gif file. We do this by using the imagemagick tool. Enter the following command :
Convert-delay 25-loop 0 *.gif example.gif
You can use any file name, I use example.gif. And, you can change this delay and cycle time.
How to record terminal operations on Linux