• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Commands

How to replay Linux session recorded by the script command

Published: August 1, 2017 | Modified: June 20, 2020



Learn how to replay the Linux session recorded by script command. Visual Linux session recording along with timing information plays past session recording in real-time.

Replay Linux session like video!

In our last article we learned how to record Linux sessions using the ‘script’ command. In this article we will walk through steps to replay recorded sessions by script command. Normally, script command saves recording in the plain text log file which can be viewed using cat, more, less, or vi commands. That would be only plain text having commands and their outputs in the order you executed them while recording.

If you want to view your recorded output as it is being played on the terminal you can do it using scriptreplay command. It will play your output just as you are typing it on the terminal! scriptreplay needs time logs as well to play recorded sessions. This time logs can be generated using –timing switch with the script command. Let’s walk through these steps.

How to record Linux session with timing

We will use script command with --timing switch followed by filename in which all timing logs will be saved.

[root@kerneltalks ~]#  script --timing=time.log capture.txt
Script started, file is capture.txt
[root@kerneltalks ~]# date
Thu Jul 27 02:42:46 EDT 2017
[root@kerneltalks ~]# hostname
kerneltalks
[root@kerneltalks ~]# echo "I love kerneltalks"
I love kerneltalks
[root@kerneltalks ~]# exit
exit
Script done, file is capture.txt

here we are saving timing information in time.log file and session recording in capture.txt file. Both are plain text files and can be viewed. If you look at time.log file :

[root@kerneltalks ~]# cat time.log
0.001666 53
0.009220 1
3.980549 1
0.103633 1
0.191978 1
0.096629 2
0.127128 75
0.000920 1
1.671676 1
0.143421 1
0.080831 1
0.152510 1
----- output trimmed----

It has two columns of data in it. The first column denotes the number of seconds elapsed after the last display action. The second column is the number of characters printed on the screen.

That’s it. You have recorded your Linux session along with timing logs. This recording (capture.txt) can be replayed using scriptreplay command since its timing information is available.

How to replay recorded Linux session

Now both logs timing and recording need to feed scriptreplay command to let the show begin! The format and switch would be the same. Command used to replay session will be :

# scriptreplay --timing=time.log capture.txt

To see it in action, I captured it in the GIF file below. See how to actually replay as if the user is typing in the terminal as it was at the time of recording!

‘scriptreplay’ command in action

It replays exactly with the same time difference between two commands as you did at the time of recording! It’s like watching what the user has done in his session in real-time. It’s more of a visual record of Linux session while script was textual records.

⇠ Previous article
Record Linux session using the script command
Next article ⇢
How to unmount NFS when the server is offline

Related stuff:

  • bdf command formatted output in hpux
  • How to change process priority in Linux or Unix
  • 5 different examples to send email through Linux terminal
  • Learn Rsync command with examples
  • File encryption / password protect file in HPUX
  • Difference between hard link and soft link
  • 12 examples of ls command in Linux for daily use
  • How to create tar file in Linux or Unix
  • YUM automatic updates! Save your valuable time!
  • 14 find command examples for Linux
  • Finger command in Linux
  • Beginner’s guide: 4 Linux group management commands

Filed Under: Commands Tagged With: record and reply terminal session, record terminal gif, record terminal session, scriptreply command, user session monitoring

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Comments

  1. Smithk508 says

    September 11, 2018 at 10:31 pm

    I appreciate, cause I found just what I was looking for. You have ended my 4 day long hunt! God Bless you man. Have a nice day. Bye ageeefekeffdefdf

    Reply

Share Your Comments & Feedback: Cancel reply

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

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2026 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.