Log a session to a file in Unix

You can use the Unix command script to log your Unix session to a file. At the Unix prompt, enter:

  script filename

Replace filename with the name you wish to give your log file. You will then see "script started, file is filename" on the screen, and you will be in a subshell (a second invocation of your login shell).

From then on, everything that you see on your screen is also written to the file filename. If you do not specify a filename, the session will be logged to a file called typescript.

To append the log to the named file rather than overwriting it, use:

  script -a filename

To end the logging of your session, enter exit at your shell prompt. This command will cause the logged subshell to exit, and you will be returned to the shell from which you invoked the script command (usually your login shell).

You can read the file using a pager command such as more or less, or open it with an editor such as Pico, Emacs, or vi. For example, to read the file using the more command, enter:

  more filename

Replace filename with the name of your file.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

This is document acbb in the Knowledge Base.
Last modified on 2023-07-14 08:47:49.