How To Record Everything In Terminal
The first option to record terminal activity on this tutorial focuses on the command Script already included in many Linux distributions by default. The easiest way to use it without flags allows to read the log file using the cat command, to run it just execute the command specifying the output file name.
In my case I saved it as “linuxhintlog.txt” as in the example below:
You’ll be able to see the script command started as shown in the image above, now you can type any command, then you can stop recording by typing “exit”.
At this stage you aren’t able to play the session in real time, yet you can read it using the cat command:
In order to play the session rather than reading it you need to add
the –timing option specifying the time file name additionally to the output file name:
In my case I saved the time file as TIMEFILE and the output file as LHoutput.txt as in the following example:
To play the recorded session the command is scriptreplay followed by the –timing flag, time file name, –typescript flag and output file name as in the example below:
In the following example the time file is TIMEFILE and LHoutput.txt the output file:
You may want to speed up or slow the playing speed, this can be achieved by using the -m (–maxdelay) and -d (-divisor) flags. With the -m option you can define the timing in seconds to play each activity, while the -d flag allows to divide it.
The following example shows how to play allowing a maximum of a second delay per command:
The next examples divides the real timing for the factor you specify, in this case I will double the speed by specifying the factor “2”.
Of course to notice the difference you must try it by yourself,
How to Record Everything in Terminal using TTYREC
Another method to record everything in terminal is the command ttyrec, but ttyrec program isn’t included by default on all Linux distributions, at least not in Debian. To install it simply run:
It’s use is pretty easy, even more than the Script command explained before. To run it just call the program specifying the output file name:
The following example shows ttyrec recording the session on a file called Lhinttyrec:
As you can see you can exit the recording session by using the “exit” command like with the script command.
To play the recorded activity you need to call the command ttyplay followed by the log file name:
Since I saved the file as Lhinttyrec I execute:
Recording terminal sessions are a good option to share knowledge, tutorial or even take tests when replying or output speed are important.The script command is the best option if you need to manipulate the playing speed, it also comes by default on Linux distributions like Debian or Ubuntu.
The Ttyrec command, despite does not come installed by default, is a good option for users who aren’t used to run commands on the terminal due the lack of flags, recording and playing requires less commands than the script program. At the end both options are pretty simple to use to record and play terminal activity. Both commands have friendly and easy man pages for users applying these commands for the first time.
I hope you found this brief tutorial on recording terminal sessions useful, thank you for reading it and keep following LinuxHint for additional updates and tips on Linux and Networking.