Purpose: If you have been using Linux for a while, chances are that you must have got your hands dirty using the shell/command-line interface (CLI) to troubleshoot some problems. Many times it’s a sequence of trial-and-error commands before you happen to give the right commands and the problem is solved and we are all happy. But the same problem comes back to haunt us again after certain months or may be even a year when we encounter the exact same problem and we wished that we had written those commands somewhere or should have pasted it in a text document and email to ourselves. In this blog entry we will see some tools that will record all your shell/terminal activities and you can replay it at a later time – just like we use to record TV shows on our VCRs and use to watch it later.
Let’s get started assuming that you are on a Debian or a Debian-based system.
Step 1: Install the bsdutils package
bsdutils is an essential Debian package so no matter what type of installation you did, you should have it installed on your system. In case if you don’t find it installed then chances are that something seriously has gone wrong with your system or soon it is going to be.
In any case, if you don’t have it then install it by giving the following command:
# apt-get install bsdutils
Step 2: Start recording your activities
Suppose you decide to record your console/shell/terminal activities just before the start of your any problem investigation. Give the following command:
# script -t 2>~/troubleshoot-wireless.time -a ~/troubleshoot-wireless.script
Script started, file is /root/troubleshoot-wireless.script
where troubleshoot-wireless is any name that you can give. You can also give test.time and test.script.
Now, you give the following sequence of commands trying to troubleshoot my wireless problem:
debian:~# modprobe ndiswrapper
FATAL: Module ndiswrapper not found.
debian:~# lsmod | grep wireless
debian:~# cat /boot/config-2.6.26-1-686 | grep WIRELESS
# CONFIG_IPWIRELESS is not set
lo no wireless extensions.
eth0 no wireless extensions.
eth1 no wireless extensions.
eth2 NOT READY! ESSID:off/any
Mode:Managed Channel:0 Access Point: Not-Associated
Tx-Power=31 dBm Sensitivity=0/200
Retry short limit:0 RTS thr=0 B Fragment thr=0 B
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Now I would like to stop recording the activities so I give the following command:
Script done, file is /root/troubleshoot-wireless.script
Step 3: View or Replay your activity history at some future time
If you just want to see the list of commands and their output you can simply give the command:
# less -R troubleshoot-wireless.script
and you should be able to see all your activities.
You may ask why the option “-R”? This is because troubleshoot-wireless.script is a binary/raw file and you just can’t view it by giving less command. You need to pass the option “-R” to tell less to display raw control characters.
Now what if you want to watch the replay of the entire session along with the timing information just like we watch a recorded TV show? Remember the “troubleshoot-wireless.time” file that we created when we first gave the “script” command? Give the following command:
# scriptreplay troubleshoot-wireless.time troubleshoot-wireless.script
Now sit back and enjoy watching your recorded hacking session. Basically the “.time” file contains two pieces of information:
a) How much time has elapsed since your last output – 1st field
b) How many characters were outputted this time – 2nd field
Here is a excerpt of my output from my “.time” file:
# less troubleshoot-wireless.time
So for example, the 3rd entry (green) tells that about 177 seconds has passed since the last output and one character has been displayed since the last output to the screen. This is the guts of the the “script” command which enables you to watch your session as a recorded video.
Trust me you will enjoy the “video like” output of your troubleshooting/hacking session. Additionally enjoy a nice hot coffee while you sit back and relax.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.
Also please don’t forget to rate this post below.