In Unix, how do I log a session to a file?

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 At IU, how do I get support for Linux or Unix?

This is document acbb in the Knowledge Base.
Last modified on 2017-05-16 11:51:40.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.