-1

I looking for the terminal history. Not only the command history that is showed by typing history but terminal processes within a command. That is, I want to record the output displayed by the commands in the terminal.

For example, One wanna install a package and types sudo apt-get install xxxx then is when terminal is telling you what is doing, it asks for confirmation, for installing additional packages, etc. –

4
  • What do you mean by “terminal processes within a command”? Apr 15, 2014 at 20:12
  • @Gilles What terminal tells that is doing when something is commanded
    – ntrpris
    Apr 15, 2014 at 20:35
  • I still don't understand. Do you mean the output from a command? Can you give an example? Apr 15, 2014 at 20:47
  • @Gilles For example, One wanna install a package and types sudo apt-get install xxxx then is when terminal is telling you what is doing, it asks for confirmation, for installing aditional packages, etc.
    – ntrpris
    Apr 15, 2014 at 20:56

2 Answers 2

6

The shell keeps a history of the commands that you type, that's what the history command gives you. There is no automatic history of the output from the commands that you run in the terminal. Once you close the terminal, the output is lost unless you saved it somewhere.

You can save a complete transcript of a terminal session by running the script command. If you run the command script, you get a new shell prompt; all the commands that you type from that point, as well as their output, are entered in the log. The log file is closed when you exit the script subsession (which returns you to the parent shell — entering exit or pressing Ctrl+D a second time exits the parent shell).

The default history file name is typescript (in the current directory). If there is already a file by that name, it is overwritten. You can specify a different file name by passing it as an argument to script, e.g. script hello.txt.

If you want to keep the history after closing a terminal, but don't mind losing the history when you switch off your computer, you can run screen or tmux.

0

Please see man history for more details:

DESCRIPTION

Many programs read input from the user a line at a time. The GNU History library is able to keep track of those lines, associate arbitrary data with each line, and utilize information from previous lines in composing new ones.

HISTORY EXPANSION

The history library supports a history expansion feature that is identical to the history expansion in bash. This section describes what syntax features are available.

History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.

History expansion is usually performed immediately after a complete line is read. It takes place in two parts. The first is to determine which line from the history list to use during substitution. The second is to select portions of that line for inclusion into the current one. The line selected from the history is the event, and the portions of that line that are acted upon are words. Various modifiers are available to manipulate the selected words. The line is broken into words in the same fashion as bash does when reading input, so that several words that would otherwise be separated are considered one word when surrounded by quotes (see the description of history_tokenize() below). History expansions are introduced by the appearance of the history expansion character, which is ! by default. Only backslash () and single quotes can quote the history expansion character.

Event Designators:

An event designator is a reference to a command line entry in the history list. Unless the reference is absolute, events are relative to the current position in the history list.


Now, to answer your question! Here are the directories, where your bash-history is saved. And YES, there is the command history, that you can access in terminal with -key located:

~/.bash_history    
/root/.bash_history

You can use cat ~/.bash_history, to see the listing/content of previous used commands. You can also open the ".bash_history", with gnome-open ~/.bash_history, in order to edit the list, or rm ~/.bash_history, to [rm=remove] the history (".bash_history" will be autogenerated, so it is save to delete it).

history-command-preview

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .