How to capture/record and replay linux terminal sessions using script and scriptreplay command in Ubuntu Linux

If you want to capture something like commands when you are installing some software, compiling some opensource codes or just want to see debug logs printed on the terminal by some program, there is command “script” which does all the work very efficiently for us. Just open a terminal, and type below command before you want things to be captured,

 $ script --timing=time.txt script.log 
Script started, file is script.log 
 devbee@laptop:~/wp$ pwd 
/home/devbee/wp 
devbee@laptop:~/wp$ cat /proc/version
Linux version 4.4.0-71-generic (buildd@lcy01-27) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #92-Ubuntu SMP Fri Mar 24 12:58:08 UTC 2017 
devbee@laptop:~/wp$ date
Sun Dec 31 09:48:05 IST 2017 
 devbee@laptop:~/wp$ time

real	0m0.000s
user	0m0.000s
sys	0m0.000s

Now, lets say, you are done with your recording, then type “exit” to stop script command running,

 $ exit
exit
Script done, file is script.log

Now to replay script recording using “scriptreplay” command, use below command,

 scriptreplay --timing=time.txt script.log 
Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question