How to record Terminal sessions as ASCII video in Ubuntu

Using asciinema, you can record and share Terminal sessions where a user will be able to select text from the video.

There are several times that you might need to record a video of a sequence of commands in terminal. Let it be for a tutorial or for teaching seasons or just for your own reference.

Recording a video does not allow you to copy from it, so you need to provide some transcript of the video if you want your viewers to be able to copy your commands for further use.

Asciinema is a nice tool to be able to share a video of your console/terminal as an ASCII video. From this ASCII video, you will see exactly the same that happened on the console while recording and you can select all texts from the video. Here is a sample video, courtesy of asciinema.

Exciting isn’t it? In this Terminal Tuts, we will guide you on how to install asciinema and its basic usage. We are using Ubuntu in this tutorial but this guide should work on Linux Mint, elementary OS and other Ubuntu derivatives.

Installing asciinema using packages

We will make the basic installation in Ubuntu using packages, but basically, the installation procedure is easy on any system, first of all, as usual, it’s better to update apt repositories before installing:

sudo apt update

Once repositories are updated, we can install the package:

sudo apt install asciinema

and that’s all, we have asciinema installed.

Installing asciinema using pip3

Pip is a package manager for Python. pip3 also is the same but when using python3, it allows to install and manage packages from Python Package Index (Pypi). We can use it to install software packages built with Python as asciinema:

If we have not pip3 installed, we first need to install python3-pip from repositories:

sudo apt update && sudo apt install python3-pip

After we have pip installed, we can just do:

sudo pip3 install asciinema

Asciinema Basic Usage

There are two ways of using asciinema, the first one is using asciinema.org service, this way, you record to asciinema cloud and you can see your recording on your account or use the embedded javascript player to replay your sessions on your webpage.

In this case, you can just record a session in your console typing:

asciinema rec

From this point, all our commands will be recorded while we just continue working on the terminal, once we have finished, we can just type:

exit

When the session is over, we will be asked if we want to upload the session to asciinema.org, if we choose yes, we will be given a hash to identify our recording.

We can also save our cast to a local file just adding a file name after rec command:

asciinema rec filename.cast

Making a local cast recording allows us to playback the file just changing the command from rec to play:

asciinema play filename.cast

We can also control the play speed with flag -s, for example, double speed:

asciinema play -s 2 filename.cast

Or limit the idle time to a given value with -i:

asciinema play -I 3 filename.cast

This will bypass any idle time above 3. Asciinema can also show all the texts as if you had recorded with ”display”:

asciinema cat filename.cast

You can also upload a local file to your desired server (defaults to asciinema.org):

asciinema upload filename.cast

We will further see in other articles on how to host your own asciinema server to serve your own casts over the web if you are not comfortable sharing them on asciinema.org.

Asciinema Advanced Options and Editing

At this point you should have a good idea about what asciinema can do for you, but there is more in the pot: asciinema can reduce death times, all the time marks will be kept but video will be played on a more fluent way. This parameter, amongst other options, can be configured by default on config file created at $HOME/.config/asciinema/config the most useful ones are:

  • command .- Used to choose the default shell command that will be opened by asciinema when the record starts, defaults to bash
  • idle_time_limit.- It can be used both on rec and play in rec config means the time from which you will not be recording when idle on the console and in play mode means the time from which you will be skipping output when idling, defaults to off
  • speed.- default playback speed (same as -s), it is a positive fraction (0.5 for 50% speed, 10 for 1000% speed), defaults to 1

You can also download a GO program (asciinema-edit) that will allow you to split content or remove idles in an already recorded cast.

Wrap Up

Asciinema is a really useful tool to record tutorials and console sessions for tests or presentations (or just self-reference), it can be easily installed on a Linux system, both as system packages or as python packages and with a simple command interface will allow you to record, light-weight ASCII casts of your console sessions. In further articles, we will see how to host your own server and embed casts or how to convert them into gifs for sharing.

Divya Kiran Kumar
I'm the Editor of FOSS Linux. I worked as a Software Engineer before taking up blogging as my full-time job. I enjoy using Linux, and can't imagine anything else for my PC. Apart from writing for FOSS Linux, I enjoy reading non-fictional books. Sapiens was my favorite last read. I hope you enjoy reading and using this blog to enhance your Linux experience! Have a great day ahead!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,647FansLike
360FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

5 Ways to Open a Terminal in Ubuntu

Even though Ubuntu supports many applications with amazing Graphical User Interfaces (GUI), there are always reasons why users prefer using the Terminal to perform different tasks.

How to install Wine on Fedora Workstation

Linux distributions are becoming more and more popular every day, and Fedora Workstation is not left behind. This popularity brings forth the need to run Windows applications on Linux distros like Fedora. Windows has quite some excellent Software that is not available for Linux.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Ubuntu 19.10 (Eoan Ermine) Beta Installation and Overview

It may be early, but I've been looking forward to the release of Ubuntu 19.10 for some time now. As an impatient person, and promised readers in the FOSSLinux article announcing the release of Eoan Ermine that we would provide you a review of Ubuntu 19.10 Eoan Ermine - Beta.  So, here it goes.

5 Best Ways to Free up Hard Disk Space in Ubuntu

Hard disk space can easily get filled up with cached package files, old kernels, and other obsolete files that occupy unwanted hard disk space. Here are top five best and safer ways to clean and free up hard disk space in Ubuntu. We show you Terminal and GUI way of cleaning up system.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.

Enabling GameMode on Linux for best gaming performance

GameMode is a combination of various libraries and daemons that allows all the users to improve the gaming performance on the Linux system. Developed by games publisher Feral Interactive, it improves gaming performance by requesting a group of options that will be applied temporarily to the Linux system.