Came across a strange case on a Ubuntu Lucid system:

bash command line is working fine most of the time, but for some reason sometimes Up doesn't work to recall previous command. It remembers the previous ones but it's like the last one got forgotten. So it has to be typed or copy-pasted back in, really annoying...

Any idea what could be causing this ?

bash version is the one that came with the distro, 4.1.5(1)-release (package: 4.1-2ubuntu3)


Commands entered with a leading space are typically not stored in bash's history. This is a feature: if you want bash not to put a command in history, such as a dangerous command like rm -rf ..., place a space in front of it. Also, duplicate commands may be ignored.

This behavior is configurable with the HISTCONTROL variable. From man bash:


A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines matching the current line to be removed from the history list before that line is saved. Any value not in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HISTCONTROL.

To see how your shell is configured, run:


To change to a new setting, edit your ~/.bashrc file.

  • Right on, .bashrc had HISTCONTROL=ignoredups:ignorespace. – riverflow Oct 16 '14 at 17:09
  • I did not know this! Thanks for the useful tip! – KevinM Mar 18 '15 at 18:19

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.