Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a novice just learning Fedora 13. I just wanted to know if its possible to redirect whatever I type in the terminal to a file, so that I would be able to see from the file, that a particular command gives this output.

So whatever I am doing should go to a file.

share|improve this question

You can use the script command. After you execute it everything that happens in your terminal will be recorded to a file which you can open up later to review what happened.

Another useful command is ttyrec which records not only the input/output of your terminal session but also timing information. This lets you to play back your terminal session later like a movie using ttyplay.

share|improve this answer
+1 for ttyrec - yet another command I had never heard of before. – Joe Nov 25 '11 at 20:37

Let's say you want to write to a new file called test.txt. Just type this on the command line:

cat > test.txt

Press enter and start writing. To finish your session press CTRL + d. A text file, test.txt will be created in the same directory, with the content you typed.

share|improve this answer

To store output in a file you can use > after the command.

Example :

ls -a > file.txt 

The above command will list all the files in the working directory into file.txt

df -h > file.txt

The above command will save your file system usage in file.txt

Hope this explanation answers your question

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.