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, 2010 at 15:21
  • superuser.com/questions/37576/…
    – warren
    May 1, 2010 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, 2010 at 20:57

2 Answers 2

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, 2010 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, 2010 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. May 1, 2010 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .