Ubuntu – Bash command history not working

bashcommand lineguakehistory

The command history between sessions is not getting saved. I'm using guake and the history for the session is working fine.

I noticed that .bash_history had some commands I executed in sudo -s mode and tried the same again and all the commands while in the session got saved so I tried:

chmod 777 .bash_history

Now the old commands appear at the start of a session but no new commands are getting saved.

Best Answer

The commands are not visible because Bash saves history to the .bash_history file only after the shell quits, and this happens very rarely with Guake. There is a simple workaround to make Bash append the history (instead of overwriting the file) after every command

shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
Related Question