How to capture your session
If you are doing a very sensitive operation on a server and you want to make sure that you can easily review your actions (and the result) afterwards you have two options:
- Rely on the scrollback in your terminal. More often than not you will run out of scrollback
- Use script
When you run script it will start a new shell that will capture all input and output into a file, the default file is called typescript. Here is an example how it works
$ script
Script started, file is typescript
$ echo hello
hello
$ exit
Script done, file is typescript
The resulting file looks like this
$ cat typescript
Script started on Thu Jun 07 08:38:27 2007
$ echo hello
hello
$ exit
script done on Thu Jun 07 08:38:40 2007
As you can see script has captured everything we typed and all the output from the commands we executed. We can now archive the typescript file in case the customer or a user asks what really happened.
Have a look at the man page for script(1) for additional information.
Do you need system administration assistance? If you like what you are reading please consider subscribing to the RSS feed. If you have feedback or if you find the article useful please leave a comment below.

