Home » Testing and Debugging » How to record and replay Linux terminal commands ?

How to record and replay Linux terminal commands ?

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 

Above command starts the screen commands recording into log file script.log. Now type the commands or do the work you want to do on the terminal. As an example, we typed below commands,

$ pwd 
/home/devbee/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 
$ date
Sun Dec 31 09:48:05 IST 2017 
$ 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
Google Chrome - How to Capture Audio
Google Chrome - How to Capture Audio

Leave a Comment