I'm running Ubuntu 9.1 and every time I open a terminal window, I lose the previous command's history. How can I configure it so it's kept even after rebooting? Thanks.

link|improve this question

What shell are you using? – fpmurphy May 1 '10 at 15:21
I get bash: PROMPT_COMMAND: line 0: syntax error near unexpected token ;' bash: PROMPT_COMMAND: line 0: ; history -a; history -n' – xain May 1 '10 at 20:57
feedback

2 Answers

up vote 2 down vote accepted

What are the permissions on ~/.bash_history? Can your user modify it?

Alternatively, are you exiting out of the previous window first?

link|improve this answer
Bingo!, for some reason it was owned by root. Thanks! – xain May 2 '10 at 0:27
feedback

I'm assuming you're using Bash.

Try this command at Bash prompt:

shopt -p histappend

If it says:

shopt -u histappend

then add this line in your ~/.bashrc:

shopt -s histappend
link|improve this answer
The output of "shopt -p histappend" is "shopt -s histappend" – xain May 1 '10 at 16:14
1  
Make sure you exit from Bash cleanly (e.g. with the exit command). Bash only updates .bash_history on a clean exit, so if the process dies unexpectedly (e.g. reboot, closing an xterm), it may not have a chance to update the file. – James Sneeringer May 1 '10 at 16:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.