Is there any way to always save the content of whatever is happening on terminal window to a file?

I want to save each and every command that is being executed and its output to a file to keep track of change history and I want to enable it up permanently on terminal.

Any suggestions pls?

  • This used to work as mentioned here: askubuntu.com/questions/161935/…, however, script does not seem to work anymore. You may want to refer to that question and indicate it does not work anymore to avoid it from being marked as a duplicate
    – vanadium
    Jan 4, 2020 at 9:18

2 Answers 2


script,from the bsdutils package is the tool you want.

script my.log 
# bunch of commands

and all the commands you typed, and all their output (including cursor control, which depends of the setting of $TERM) will be saved in my.log.

From the man page:

bionic (1) script.1.gz
Provided by: bsdutils_2.31.1-0.4ubuntu3_amd64 bug


       script - make typescript of terminal session


       script [options] [file]


       script  makes  a  typescript  of  everything displayed on your terminal.  It is useful for
       students who need a hardcopy record of an interactive session as proof of  an  assignment,
       as the typescript file can be printed out later with lpr(1).

       If  the argument file is given, script saves the dialogue in this file.  If no filename is
       given, the dialogue is saved in the file typescript.

You can use this for appending to a file without overwriting.

your_command >>/path/to/file

You can also check .bash_history for the order of commands.

This answer might help.

  • Question is to save anything that is also printed to the screen into a file. Your answer 1) requires to add the redirection to each command and 2) will not print the command itself
    – vanadium
    Jan 4, 2020 at 9:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .