2

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?

3
  • What shell are you using? – fpmurphy May 1 '10 at 15:21
  • superuser.com/questions/37576/… – 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
2

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

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

1
  • Bingo!, for some reason it was owned by root. Thanks! – xain May 2 '10 at 0:27
2

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
2
  • 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

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.