Save shell command history effectively September 18, 2005Posted by Carthik in commands, guides, ubuntu.
You should know as a beginning linux user that at the terminal you can press the up arrow to visit the previous commands that you have executed. The bash shell by default saves the last 500 commands (or fewer, if there aren’t that many to save), for easy recall.
However, by default, bash overwrites the history file when you close a session, or a terminal window, saving only those commands that were used in the last session. This can be annoying if, for example you have one terminal window open, and then you open another one, and close the new one after a few commands.
By adding the following line to ~/.bashrc , you can ask bash to append to the history file, thus preventing the overwriting:
shopt -s histappend
I find this pretty useful since I have discovered it.
You can find a detailed explanation of what I tried to say above, with pictures 😉 at the Power Shell Usage guide. You will also find a lot of other useful tips.