If you are a frequent terminal user, you may come across situations where you need to debug the code or copy the output of a script for future reference. For such cases, you may want to record the terminal session to obtain the log file of all the input commands you have entered and their outputs. Here is one way that you can use to record terminal session in Ubuntu.
Open a terminal and install
Once installed, you will be able to use two commands
scriptreplay to record the existing session and play back the recording.
The usage is pretty simple. To start the recording, you just need to use the command:
Remember to change the file path to a valid file location. For example, if I want to save the recording to my Home folder, this is what I type:
-t” flag instructs the script to output the timing data while the “
-a” flag instructs the script to append the output.
Once you entered the command, you should see the line “
Script started...“. Everything that you enter in the Terminal (including its output) will now be recorded.
Once you are done with the recording, simply type
exit to end the recording. You should see the line “
Script done,...” that denotes the end of recording.
To view the recording, you can either open the saved file (recording.txt) in your text editor or use the command
That’s it. While it is simple, it can be really useful for debugging, or even troubleshooting your friend’s computer by showing them what you have typed and the expected output they should see in the terminal.
Is this helpful to you? What other uses can you think of?
Image credit: Macro Of Digital Dictaphone by BigStockPhoto