Celeb Glow
general | February 28, 2026

Bash is losing history even though shopt -s histappend is set

I lost all commands that were executed from the last session - they do not show up in history at all. What needs to be done to prevent this??

I had added

shopt -s histappend

just for this purpose .. but it is either not taking at all or at the very least not reliably.

~/spark >shopt | grep histappend
histappend on

2 Answers

Following combination seems to be working:

unset HISTFILESIZE
HISTSIZE=10000
PROMPT_COMMAND="history -a"
export HISTSIZE PROMPT_COMMAND
shopt -s histappend

Check permissions in the .bash_history file (and its parent)

Sometimes this is deliberately changed to prevent history from being used (and potentially capturing things like passwords in the command line)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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