On this Debian Jessie installation, Bash history seems to be behaving inconsistently in Gnome Terminal:

$ echo $USER
$ echo $HISTFILE
$ grep browser ~/.bash_history 
browser-sync start
$ history | grep browser
 2071  grep browser ~/.bash_history 
 2073  history | grep browser

The browser-sync line from the ~/.bash_history file is quite old: much older than the current Terminal session. Why isn't it showing up in the results from history | grep browser?

  • 2
    Possibly they're too old to have been loaded into the active history in memory?
    – Tom Hunt
    Commented Dec 1, 2015 at 17:49
  • @TomHunt, spot on, thanks. I've expanded your comment into an answer, below.
    – user6860
    Commented Dec 1, 2015 at 18:23

2 Answers 2


By default, ~/.bash_history is written to disk when an interactive session terminates. This means that if you have concurrent shells open, only the most recently terminated shell session has its history written to disk.

(technically, all sessions are written to disk, but two concurrent sessions don't know about the others' histories, so when one exits, it writes what it thinks the new history to be, and then when the other exits, it writes its history)

See https://unix.stackexchange.com/a/1292/20246 for more details.

  • 1
    Thanks for the suggestion, but this answer does not actually answer my question. Based on @TomHunt's comment above, I was able to identify a fix for the issue: see my answer.
    – user6860
    Commented Dec 1, 2015 at 18:24

The $HISTSIZE variable has too low a value. The apparent inconsistency can be resolved by sufficiently increasing the value of $HISTSIZE.

The Bash manual doesn't explain it very well:


The maximum number of commands to remember on the history list. If the value is 0, commands are not saved in the history list. Numeric values less than zero result in every command being saved on the history list (there is no limit). The shell sets the default value to 500 after reading any startup files.

Here is a better explanation:

The default value for HISTSIZE (500) would load only a fraction of the saved history [if the saved history is greater than 500 lines].

You must log in to answer this question.