bashunix

Unlimited Bash History


I want my .bash_history file to be unlimited. e.g. So I can always go back and see how I built/configured something, or what that nifty command was, or how some command broke something weeks ago. How do I change this setting?


Solution

  • Set HISTSIZE and HISTFILESIZE in .bashrc to an empty string:

    HISTSIZE= 
    HISTFILESIZE=
    

    In bash 4.3 and later you can also use HISTSIZE=-1 HISTFILESIZE=-1:

    n.  Setting HISTSIZE to a value less than zero causes the history list to be
        unlimited (setting it 0 zero disables the history list).
    
    o.  Setting HISTFILESIZE to a value less than zero causes the history file size
        to be unlimited (setting it to 0 causes the history file to be truncated
        to zero size).
    

    bash --version to check your bash version.