Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to record terminal operation on Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to record terminal operation on Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to record terminal operation on Linux.

Recording a terminal action may be an easy-to-understand way to help others learn Linux, demonstrate a series of correct command-line operations, and share knowledge. No matter what the purpose, copying and pasting text from the terminal needs to be repeated many times, and the process of recording a video is quite troublesome, and sometimes it cannot be recorded. In this article, we will take a brief look at how to record and share terminal conversations in gif format.

Advance requirement

If you just want to record your terminal conversation and play it back or share it with others on the terminal, then all you need is 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 that you can share it with those who don't use the terminal, you can post it to the website, or you just want to make a gif easy to use and don't want to write commands. Then you need to install two additional packages. * these are imagemagick. You can install them with the following command:

Sudo apt-get install imagemagick

Sudo apt-get install imagemagick

The second package is tty2gif.py, which can be downloaded from its project website. 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 press enter. This command will run a real-time logging tool in the background. We can stop it by typing exit or ctrl+d. Ttyrec creates a ttyrecord file in the home directory by default.

Playback

It is very easy to play back this file. You just need to open the terminal and use the ttyplay command to open the ttyrecord file. (in this example, we use ttyrecord as the file name, of course, you can also change it to your file name.)

Then you can start playing the file. This video records all the actions, including your deletions and modifications. It looks like a self-aware terminal, but the process of executing the command is not just to show it to the system, but to show it to people better.

Note that playing this record is completely controllable, you can accelerate and decelerate by clicking + or -, or pause and resume playback by 0 and 1.

Export to GIF

For convenience, we usually convert video records to gif format, and this is very easy to do. Here are the methods:

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 there is an error, check to see if you have installed the python-opster package. If there are still any errors, use the following command to troubleshoot.

Sudo apt-get install xdotoolexport WINDOWID=$ (xdotool getwindowfocus)

Then repeat the command 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 package it 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 example.gif. And you can change the delay and cycle time. Enjoy .

At this point, I believe you have a deeper understanding of "how to record terminal operations on Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report