Record your console session

Posted August 8, 2016 by Adrian Wyssmann ‐ 1 min read

If you ever wanted to record what you are doing on your console, use script. Man page says

make typescript of everything displayed on your terminal

This is very handy, especially to record your interactive session and keep the information for later or even print it out. Simply start your session with

[[email protected]]$ script <filename>
Script started, file is <filename>

Afterwords you can start working with your shell. When you want to end the recording, you simply type

[[email protected]]$ exit
Script done, file is {filename}

Afterwards you can see your activities in the specified {filename}. I usually prefer to define an alias, so I don’t have to worry about the filename and I avoid to overwrite existing session recording

alias script='script ~/Sessions/`date +%Y%m%d%H%M`.txt'
[[email protected]]$ script
Script started, file is /home/user/Sessions/201403081038.txt
[[email protected]]$ exit
Script done, file is /home/user/Sessions/201403081038.txt