Skip to main content

How to record your Linux terminal using asciinema

Asciinema might be the application you've been looking for to demonstrate a skill or process that you want your colleagues or students to learn on-demand.

In my line of work, as well as in many hands-on technical positions, there are times when recording your work is necessary. Sometimes, it’s an advanced form of note-taking; other times, it's a quick and easy way to send someone junior a how-to. You could even record your terminal for "insurance" if you are the paranoid type. Either way, there is no denying that terminal recording software is a neat and practical tool to have in your arsenal.

So, in exploring some of the various ways to do this, I came across what is easily my favorite terminal recorder. Asciinema (pronounced as-kee-nuh-muh) is a free, open source software built exclusively for terminal session recording. But it allows you to take the recordings a step further and share them via the web (you can send an embed code or the source file as needed).

[ Readers also liked: Sysadmin skills: What junior sysadmins need to know ]

Installation

For the examples you will see below, I am using a Fedora 33 workstation. For information on installing to other operating systems, see the install documentation.

To install: sudo dnf install asciinema

From my terminal:

[tcarrigan@client ~]$ sudo dnf install asciinema
[sudo] password for tcarrigan: 
Fedora Modular 32 - x86_64                       26 kB/s |  14 kB     00:00    
Fedora Modular 32 - x86_64 - Updates             62 kB/s |  14 kB     00:00    
Fedora Modular 32 - x86_64 - Updates            184 kB/s | 182 kB     00:00    
Fedora 32 - x86_64 - Updates                     33 kB/s |  14 kB     00:00    
Fedora 32 - x86_64 - Updates                    3.3 MB/s | 6.2 MB     00:01    
Package asciinema-2.0.2-2.fc32.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

As you can see above, the install is complete. Now, how do we actually make use of this software?

Basic usage

The most basic use of this software is to create a recording, so that is where we will start. To start recording your terminal, you will use the command:
asciinema rec [filename] . At this point, you will want to run whatever commands that you wish to record. When you are ready to end the recording, you will use Ctrl + D or type exit. Here’s what this looks like.

[tcarrigan@client ~]$ asciinema rec terminal_rec_demo
asciinema: recording asciicast to terminal_rec_demo
asciinema: press <ctrl-d> or type "exit" when you're done
[tcarrigan@client ~]$ This is how you record a terminal session. When finished...just use Ctrl+D
bash: This: command not found...
[tcarrigan@client ~]$ exit
asciinema: recording finished
asciinema: asciicast saved to terminal_rec_demo

You can now find the raw file in your home/user directory.

[tcarrigan@client ~]$ ls -l
total 752
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Desktop
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Aug  3 21:48 Documents
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Downloads
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Music
drwxr-xr-x. 2 root      root        4096 Jun 25 16:48 p
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Pictures
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Public
-rw-rw-r--. 1 tcarrigan tcarrigan  32553 Nov  6 17:12 tail_demo
-rw-rw-r--. 1 tcarrigan tcarrigan 690827 Nov  6 17:12 tcpdump.txt
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Templates
-rw-rw-r--. 1 tcarrigan tcarrigan   2532 Dec  7 15:14 terminal_rec_demo
drwxrwxr-x. 3 tcarrigan tcarrigan   4096 Jun 25 16:48 test
drwxr-xr-x. 2 tcarrigan tcarrigan   4096 Jun 24 12:29 Videos

Now that you have your recording, how can you share it? That is where this tool gets really neat.

Sharing

In order to share your recording, you need to first get the file onto the web. You can start by uploading your file to the asciinema.org site. To do this, you will use the upload <filename>command. Now, for this to work, you need to authenticate your terminal with your account on the asciinema website. For more information on how to do this, you should see the "auth" section of the following webpage (toward the bottom).

Once you have uploaded your recordings to the webpage, you can log into your account and view them. Once you are here, it’s as simple as grabbing the embed code or URL and using it as needed. If all goes well, you should see something very similar to the following example.

 

This is the final product from the output in the "Basic Usage" section.

[ Get this free ebook: Managing your Kubernetes clusters for dummies. ]

That's a wrap

If you found this helpful, I encourage you to give this tool a try in your next blog or, when someone needs you to show them how to do it, you can just send them this recording so that they can reference it as needed!

Topics:   Linux   Command line utilities  
Author’s photo

Tyler Carrigan

Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.