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
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
Script done, file is script.log

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

 scriptreplay --timing=time.txt script.log 
READ  How to encrypt directory / folder in Linux using Encfs - Ubuntu 16.04

Leave a Reply

Your email address will not be published. Required fields are marked *