Home Command line utilities Record Terminal Sessions Using Asciinema In Linux

Record Terminal Sessions Using Asciinema In Linux

By sk
Published: Updated: 1.3K views

We already know how to record the Terminal activities using "script" command in Linux and Unix-like systems. In this guide, we will be discussing how to install Asciinema in Linux and how to record Terminal sessions using Asciinema. We will also see how to share the recorded terminal sessions on the web.

What is Asciinema?

Asciinema is a fast, light-weight and open source Terminal recording tool. Unlike "script" command, Asciinema not just records our Terminal activities, but also helps us to share them on the web if necessary. You can share the recordings by copying its URL and sending it to a friend or posting it on a social network. It supports Linux, Mac OS X and *BSD.

Asciinema tool could be useful in the following situations:

  • The online trainers can record and share the Terminal session when teaching Linux commands to the students.
  • The students can share their Terminal activities to their online tutors when they have been given a command-line assignment.
  • The junior admins can record and share their Terminal activities to the remote technical support or subject matter experts when looking for help.
  • Technical writers or bloggers can record the terminal activities and use them while writing a book or blog post.

The possibilities are endless. Whatever it is, when it comes it to record a terminal session, Asciinema comes in handy!

Install Asciinema On Linux

Asciinema has been packaged for almost all Linux distributions, and it's available in the official repositories of many Linux distros.

On Arch Linux and derivatives like Manjaro Linux, enable [Community] repository and run the following command to install asciinema.

$ sudo pacman -S asciinema

On Debian, Ubuntu, Linux Mint:

$ sudo apt install asciinema

On Ubuntu versions, you need to enable [Universe] repository to install asciinema.

$ sudo add-apt-repository universe

There is also a official PPA is available for Ubuntu and its derivatives.

$ sudo apt-add-repository ppa:zanchey/asciinema
$ sudo apt-get update
$ sudo apt-get install asciinema

On older RHEL and its clones:

$ sudo yum install epel-release
$ sudo yum install asciinema

On latest Fedora, RHEL, CentOS, AlmaLinux, Rocky Linux:

$ sudo dnf install asciinema


$ sudo zypper in asciinema

Install Asciinema as snap

Asciinema also available as snap package. You can install Snap on Arch Linux and Fedora as described here.

$ sudo snap install asciinema --classic

Install Asciinema using pip

$ sudo pip3 install asciinema

Your system should have pip3 installed before installing asciinema.

Install Asciinema from source

If none of the above methods works, you can manually compile and install it from source as shown below.

Your system should have Python 3 installed to compile Asciinema from source.

$ git clone https://github.com/asciinema/asciinema.git
$ cd asciinema
$ sudo python3 -m asciinema --version

To install asciinema on Unix and other operating systems, refer the asciinema installation page.

Record Terminal Sessions Using Asciinema In Linux

When you run "asciinema" without any argument, it will display the help section.

$ asciinema
usage: asciinema [-h] [--version] {rec,play,cat,upload,auth} ...

Record and share your terminal sessions, the right way.

positional arguments:
rec Record terminal session
play Replay terminal session
cat Print full output of terminal session
upload Upload locally saved terminal session to asciinema.org
auth Manage recordings on asciinema.org account

optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit

example usage:
Record terminal and upload it to asciinema.org:
asciinema rec
Record terminal to local file:
asciinema rec demo.cast
Record terminal and upload it to asciinema.org, specifying title:
asciinema rec -t "My git tutorial"
Record terminal to local file, limiting idle time to max 2.5 sec:
asciinema rec -i 2.5 demo.cast
Replay terminal recording from local file:
asciinema play demo.cast
Replay terminal recording hosted on asciinema.org:
asciinema play https://asciinema.org/a/difqlgx86ym6emrmd8u62yqu8
Print full output of recorded session:
asciinema cat demo.cast

For help on a specific command run:
asciinema <command> -h

Record terminal sessions

To record a terminal session, simply run:

$ asciinema rec test

Once you run the above command, you will see the following output.

~ Asciicast recording started.
~ Hit Ctrl-D or type "exit" to finish.

Asciinema will now start to record the Terminal activities and save them in a file called "test" in the current working directory.

Let me type some random commands.

$ echo "Welcome to OSTechNix"
$ uname -a
$ pwd
$ touch ostechnix.txt
$ df -h

That's enough. To finish the recording, press "CTRL+D" or type "exit".

When the recording is ended, you will see the following message.

~ Asciicast recording finished.

Playing the record session

You can play the recorded Terminal session with command:

$ asciinema play test

Replace "test" with your filename.

Here is Asciinema in action.

Record Terminal Session using Asciinema in Linux

Record Terminal Session using Asciinema in Linux

Uploading the record session to asciinema.org website

If you don't specify filename for the recording, you will asked to upload the resulting recording to asciinema.org website, so you can share it to your friends or social media or add it to your own blog/website.

Here is the sample output when you don't specify the file name.

~ Asciicast recording finished.
~ Press <Enter> to upload, <Ctrl-C> to cancel.

Press ENTER key to upload the recording to asciinema site. You will get an unique web URL like below after few seconds.


Just share it to your colleague or friend or whoever wants to view your Terminal session in their web browser. Or, you can view it on your own browser itself. Once your friend entered the above URL in their browser's address bar, they can be able to see your recording.

As stated earlier, you can even share the recordings on social networks or embed them on other websites or on your own blog.

To share the recording session, just click share button on the bottom right corner.

Share asciinema recording on the web

Share asciinema recording on the web

You can also download it if you want. To do so, just click the Download button in the bottom.

Download asciinema recordings from the web

Download asciinema recordings from the web

All your recording will be kept as private. So, they will not listed on any search engines or other websites. They will be only visible to someone you give the URL.

Delete recordings

To delete the recorded Terminal session, click on the Gear button next to "Download" button in the bottom, and hit "Delete" option.

Manage your recordings on asciinema.org site

You can manage your uploaded sessions on asciinena.org site. To do so, you need to authenticate to the site by running the following command on the Terminal:

$ asciinema auth

You will be given an unique URL like below.


Open the above URL in a browser to register your API token and assign any recorded asciicasts to your profile.

Enter your details and click Save to create your profile.

Manage your recordings on Asciinema site

Manage your recordings on Asciinema site

Now, you can edit, set title/description to your uploaded recordings and also you can delete if you don't want to keep them in online anymore.

Suggested read:


Acsiinema is simple, yet very useful. The "script" command helped me to record my Terminal session and view the recorded session later. However, Asciinema utility allowed me to share my recorded terminal sessions with other users. Give it a try, you won't be disappointed.


You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More