As far as I know you can't. You can only go back as far as the history buffer was set. If you're asking about what package you could install to indefinitely save command history in the future, perhaps you should revise your question.
–
hbdgafJul 7 '12 at 6:35

It's not true that history is only saved from one terminal/shell. When you run history, it shows the current shell's history as most recent, and history from all other shells (including shells in previous sessions, including across power cycles) before that. All shell instances save their history to .bash_history when the exit. No instances save it there automatically, before that point.
–
Eliah KaganJul 12 '12 at 2:57

Something that might also be of interest to you is how to search through your previous command history. You can reverse search your history on the command line by pressing Ctrl+r and then typing letters you wish to match. If you have more than one matching command, press Ctrl+r again. To quit the reverse search, press Ctrl+g.

By default, there is no place where all commands are recorded and kept indefinitely, although ~/.bash_history contains the past few commands (if you use bash, which is the default shell in Ubuntu).

If you want every command typed in bash recorded forever, you have to set it up yourself. For example, you can put the following in your ~/.bashrc file to log all the commands typed in a bash shell to the file ~/.command_log:

The above sets a trap on DEBUG, which is executed just before an ordinary command is executed. The caller built-in is used to test whether the command is being typed at an interactive shell or run via something like ~/.bashrc. The value ${BASH_COMMAND} contains the command currently being executed.

You can only go back so far as your history limit is set; once it has reached that point the history will start to be overwritten. However, it is possible to have a larger history size for the future. Put this in your .bashrc and specify a value (mine is set at 1000):