How to record your terminal operation and playback on Linux _unix Linux

Source: Internet
Author: User
Tags imagemagick

Objective

Let's say you're a reliable man, and whenever your friends and family are having problems with Linux, it's always the first time you ask for help. Someone will ask you how to install and configure a tool, and then you want to tell the specific steps. But what if the other person is not in front of you? There may be a number of solutions, such as putting specific steps into a document and sending it through e-mail, or calling, detailing, and so on, but the most definitive solution is for you to demonstrate yourself. If the demo only needs a terminal, then the best way is to record your terminal operation.

Recording a terminal operation can be a popular 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 the terminal needs to be repeated many times, and the process of recording the video is quite cumbersome, let's take a look at how to record your terminal operation.

Prior requirements

If you just want to be able to record your terminal session and be able to replay it or share it with others, you only need a software called:ttyrec . Ubuntu users can run this line of code to install:

sudo apt-get install Ttyrec

If you want to convert the generated video into a GIF file, you can share it with people who don't use the terminal, or you just want to make an GIF easy to use rather than write commands. Then you need to install an additional two packages.

The first is ImageMagick , you can install the following command:

sudo apt-get install ImageMagick

The second package is:tty2gif.py, visit its project website to download. This package needs to be installed with the following dependencies:

sudo apt-get install Python-opster

Recording

To start recording terminal operations, all you need to do is type ttyprecand 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

Playback of this file is very simple. 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 to the file name you use)

You can then start playing the file. This video records all the operations, including your deletion, modification. It looks like a terminal with a sense of self, but the process of executing the command is not just for the system to see, but for better presentation.

note that the playback of this record is completely controllable and you can pause and resume playback by clicking + or-accelerating deceleration, or 0 and 1.

Export as GIF

For convenience, we typically convert video records 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), and 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 there is still an error, use the following command to exclude it.

sudo apt-get install xdotool
export windowid=$ (Xdotool getwindowfocus)

Then repeat this command Python tty2gif.py and you will see a few more GIF files in the Ttyrecord directory.

The next step is to consolidate all the GIF files and package them into a GIF file. We use the imagemagick tool. Enter the following command:

Convert-delay 25-loop 0 *.gif example.gif

You can use any file name, I use the example.gif. And, you can change the delay and the cycle time.

I hope this article will help you learn Linux and thank you for your support to the cloud-dwelling community.

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: info-contact@alibabacloud.com 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.