bash history is my memory, it contains commands that I don't want to loose when I update to a newer version of Ubuntu or change my computer.
Is it possible to transfer the commands database to a fresh installation?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Your bash history is saved in a plain text file, called by default
Unless you modified the
$HISTFILE variable you should find it in your home directory:
$ echo $HISTFILE /home/sylvain/.bash_history
If you keep your home partition when updating or reinstalling your system and if
$HISTFILE is saved on this partition, there's nothing else to do.
To transfer the file to a new computer, just save it on a USB drive and replace the existing
.bash_history of the target system.
HISTTIMEFORMAT was set on the "old" system, don't forget to set it again otherwise the timestamps of the new commands won't be saved as comments in the "new"
In case you would like to merge both old and new with new being saved at the end of the history file, you can use this method:
sudo apt-get install moreutils cat .bash_history.old $HISTFILE | sponge $HISTFILE