I am going to have all my data transferred to a new PC. Is it possible to transfer the command history of the previous Linux to the new system as well? So that when I type the history command, I get the same results as I did on the old system.


If you're using Bash then the history is kept in the file, .bash_history, in your home directory.

This file can be copied from one system to another, it's just a text file.


$ tail -4 ~/.bash_history
alias|grep cdc

The file is filled with lines that include a timestamp followed by the command that ran at that timestamp.

  • 2
    It may be worth noting that the history file can be stored elsewhere, if the HISTFILE environment variable is re-set. Its default is certainly ~/.bash_history, however. – a CVn Nov 24 '13 at 21:27

If you transfer the home directory contents as well, then yes. In bash it's /home/user/.bash_history, for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.