Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Saturday, May 16, 2015 at 20:53

We know that our Terminal (more precisely, our bash) saves commands history in .bash_history file. But we also know that our Terminal doesn't save the output of every command. How if we want to do that and save output as a text file? For example, we want to analyze every command output or learn how apt-get works (like me). We can do it with a program named script from util-linux package from Linux Kernel Archive. The program is pre-installed in Ubuntu. I will show you how to use it and how to run it every time Terminal starts.

How To Use script

As I said above, script program is pre-installed in Ubuntu. To use it, just type script in Terminal. Then use your Terminal as usual. To stop script from recording, press Ctrl+D in Terminal. The record is saved in Home by default. The record is named typescript (yes, without any .txt extension) by default.

Recording All Terminal Output as Text
You can open the history file typescript with Gedit.

Open Terminal Output History

Recording With Custom File Name

Just use command script customfilename.txt. See picture below.

You can change the name as you want.

Recording in Terminal Every Time

If you want to record all Terminal output without typing script command every time new Terminal opens, you can configure it easily in GNOME Terminal preference. As an example, you can use command script --append /home/ubuntu/Documents/history.txt.

At anytime you start Terminal, you will see a message like this:

You will find the record in /home/ubuntu/Documents/history.txt file path.