4

I want to create a text file which will add each command I am going to run on the terminal as a new line entry in the text file. i.e., I need to keep a record of what are the things I'm doing in the terminal. Further if I can keep a record of outputs I'm getting in the terminal, along with the inputs in the terminal, as a text file, it will be much better.

Each time I forget a command I have to search again in the Internet for the command.
Can I can make a file like above?

αғsнιη
  • 35,660
Praveen
  • 1,015
  • 4
  • 14
  • 26
  • 1
    Yeah, you can run the command history to see a list of run commands. Run all commands with the >> file.txt and it will all be saved there. – Tim Dec 06 '14 at 11:07
  • history is nice. – Praveen Dec 06 '14 at 12:16
  • 1
    ...but there are several more, for example this one: http://askubuntu.com/questions/485495/how-to-both-display-a-command-lines-output-on-console-and-save-the-output-into – Jacob Vlijm Dec 07 '14 at 07:59

2 Answers2

7

You can use script to make typescript of terminal session. It will record all the inputs and output to a file. To start recording type in terminal,

$ script

Go on doing your regular job. To end the recording use Ctrl+D. All the typescript will be saved in the file typescript located at the directory where you opened the terminal.

To save all the log in your desired file, use

$ script /path/to/mylogfile.txt

Usually script comes with default Ubuntu installation.

sourav c.
  • 44,715
0

Comment by tim will solve the first part of the question.

Running history on terminal shows the commands previously ran on terminal.

Running history >> file.txt on terminal creates file.txt in home directory which has as entry the commands previously ran on terminal.

Praveen
  • 1,015
  • 4
  • 14
  • 26