ISO27001:2013
Certified Supplier

FIND OUT MORE

We're an ISO27001:2013 Certified Supplier

blog-post-featured-image

The script command will record all keystrokes typed in a shell session to a file. Maybe you know about that, but if you’re using script to help with training, there’s some extra functionality that may be helpful.

Firstly, the script command itself. This can be useful when running a long sequence of commands by hand; for example, when carrying out a system upgrade, you may have a set of steps to follow. By using script to record all the keystrokes, in the event that there are problems you have an effective audit log of what was typed:

Now, all commands typed, together with the system prompt, will be recorded in upgrade_system.script.

Tip: because script also records the shell prompt, if your prompt contains escape characters, they too will be written to the file.

You may want to start your script recording as follows:

That will reset your prompt just for the duration that you are recording the keystrokes.

To stop recording:

Training

If you’re recording keystrokes for future use as a training aid, this may be helpful:

If you now run some commands and end with exit, the commands can be replayed with the same timing as follows:

The rate of playback can be changed; see the scriptreplay(1) man page.

Was this tip helpful?

Let us know in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *