save Linux terminal history to a file

 
If you want to save the terminal history in another file, use the following command:

history > history_file.txt

This new file will contain also and the commands used in your currently opened terminal session.1

A new file called history_file.txt will be created in your currently working directory containing your last used commands (by default HISTSIZE=1000 and HISTFILESIZE=2000, but you can change these values in ~/.bashrc).

  1. There is a hidden file in your home directory called .bash_history. In a default configuration, this doesn't contain the commands used in your current opened terminal session.

References


View or Post Comments