There is of course also bash's history mechanism. If enabled, bash will keep a file ~/.bash_history which contains all command lines that you entered, up to a maximum number of entries.
There's also the fc command to browse the history without looking through the file, for instance fc -l 1 | fgrep echo to list all history lines containing echo anywhere.
All of this of course can be configured:
HISTFILE sets the name of the history file, instead of ~/bash_history
HISTSIZE sets the maximum number of entries that are kept in the history (defaults to 500).
HISTCONTROL allows some fine tuning about what is kept in the history and what not. By setting HISTCONTROL=ignoreboth duplicate entries are kept only once, and you can prevent single command lines from showing up in the history by prepending a space (e.g. ls instead of ls).
I like to keep HISTSIZE as large as I can without slowing down my machine, that's typically around 50000 or so before it gets noticeable. This way I can go back for months if I don't remember that one difficult pipeline or whatever and I need it again.
( I'm not using bash myself, only zsh, but from what I gather from the manpage the mechanism is similar. Someone please correct me if I got the details wrong. )