Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I do not know if this is even possible or not, but in an attempt to keep track of many changes I am about to make to my system I want to track all input I type and all output from a terminal I'm working with to a file. I've been messing around trying to do this and here is what I have so far:

bash > /tmp/output.txt

This has some quasi success. I tested this with something simple: sudo apt-get update && sudo apt-get upgrade which dumped the normal output to the file, but not what I typed in.

Additionally I'd like to be able to see the output as well as have it stream to my output file, just for readability. (This can be worked around with a second terminal running tail -f, but it'd be nice to have it in one place).

share|improve this question

4 Answers 4

up vote 5 down vote accepted

Use the Script Command

You probably want the /usr/bin/script command. It creates a typescript of your current terminal session. It won't work very well with curses-based applications, but works very well for creating a typescript.

For example:

script ~/terminal_session.txt
echo foo
echo bar > /dev/stderr

will send everything you see on the screen to the named text file.

share|improve this answer
Thanks you, that's exactly what I was looking for –  BCqrstoO Jan 30 '14 at 18:37

For a precise recording of a text session, including timing, without messing up full-screen applications, you can use ttyrec.

For interactive applications where text scrolls by, you can use the script command.

share|improve this answer
This is interesting, thanks for this info –  BCqrstoO Jan 30 '14 at 19:08

You're looking for script:

     script makes a typescript of everything printed 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 all dialogue in file.  If no
     file name is given, the typescript is saved in the file typescript.

This should be installed by default on most Linux systems since it is part of the util-linux package. To use it, just start a your shell like this:

script session.log

Now, go about your business as usual, it should be completely transparet to you. When you're done, hit Ctrl + D or run exit. That will save everything you did into session.log.

share|improve this answer

I don't think you can do exactly what you're asking for.

However, if you want a record of what you've done the script command is probably what you want. It records all typed-in input and all output to a file. It's a text file, usually named "typescript". You will find it in the directory in which you started script.

script is part of the util-linux package under Arch linux.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.