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,


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


$ 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
lynxbee_ezoic

Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded