Recording Program Interaction

Learn how to record program interaction.

The script command

We’ve seen that the shell records the history of the commands we run on the system, but we can also record the output of those commands thanks to the script command. This is incredibly useful for logging a shell session to share with others to get debugging help or demonstrate how we did things. The official description in the documentation for script even states that one of the uses is for students who “need a hardcopy record of an interactive session as proof of an assignment.”

To use it, we execute the script command, followed by a file name for the output. The resulting log becomes a text file we can edit or reformat, making it a great documentation tool

script myscript.txt

Get hands-on with 1200+ tech skills courses.