Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
What shell are you using? – fpmurphy1 May 1 '10 at 15:21… – warren May 1 '10 at 17:44
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
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?

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

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
share|improve this answer
The output of "shopt -p histappend" is "shopt -s histappend" – xain May 1 '10 at 16:14
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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