How to record terminal operations on Linux

Source: Internet
Author: User
Tags imagemagick

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 will simply learn how to record and share a terminal session in GIF format.


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, access to its Project site download. This package requires the following dependencies to be installed :

sudo apt-get install Python-opster


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 .


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 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 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 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.