This question already has an answer here:

I don't know how to best describe this, but I am looking for a way to capture everything that's happening on one terminal, onto a file.

For example, I have this on my terminal screen:

yes@yes:/dev/pts$ echo "asdfasdf"
yes@yes:/dev/pts$ sadsad
sadsad: command not found
yes@yes:/dev/pts$ tail /etc/passwd
usbmux:x:112:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
pulse:x:113:116:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
yes@yes:/dev/pts$ testing terminal yohoho
testing: command not found

And I want this, exactly as it is (with all the information here, including the commands I run and the output of the terminal), to be exported into a file.

What I tried was something pretty naive, which obviously failed, was to run this from another terminal:

cat /dev/pts/0 > ~/testfile

The reason I want to know how to do this is because I often have to work with files that are very large on remote machines with no ftp available, so being able to "cat" the files on the terminal, and have the output of the terminal automatically be exported on a file on my machine would be really useful.

marked as duplicate by muru, user4556274, mosvy, Thomas Dickey, Jeff Schaller Jun 20 at 11:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use the script command, like so:

script filename.txt

Whatever you enter in the terminal or whatever gets displayed on the terminal will be stored in filename.txt.

To stop the process press CtrlD in the terminal where you have started script.

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