6 Logging

When you use Linux as a host, you don’t have PuTTY anymore. Well, that a lie because PuTTY is ported from Windows back to Linux now. You can install putty using the following command (as root or use sudo):

aptitude install putty  
  

Once you install PuTTY, then logging a session is the same as before.

On the other hand, you can also use a cool alternative to log your homework sessions. Install the script package first:

aptitude install script  
  

What is so cool about script is its ability to replay a session, including all the backspacing and etc. You should run script before SSHing into a VM, and exit (use the command exit) script after logging out from the SSH session.

By default, script creates a log file called typescript in the current working directory. However, you can also supply a redirection to record timing information. Observe the following command to start script:

script -t 2> timing  
  

This starts to log all subsequent commands to a file named typescript, but it also records timing information in a file called timing. When you are done with the session to be recorded, type exit to end the logging.

Alternatively, you can supply the command to script as follows:

script -c "ssh -p 2222 localhost" -t 2> timing  
  

You can, then, replay the sequence (only for display purposes, the commands won’t be run again) using the following command:

scriptreplay timing  
  

This command assume the log is stored in typescript, and only use timing as the file for timing purposes.