50

I recently replaced my Ubuntu 14.04 installation with Ubuntu Gnome (which comes with Gnome DE). But I noticed that bash history is not saved once the terminal session is closed. Once I close a terminal session and open a new one, and run the command history it does not show anything other than the history command itself. Is there any way to solve this issue?

Thank you

Deepal
  • 1,676

2 Answers2

85

It may be that your .bash_history doesn't belong to your user. Check the permissions of the file and if you're not the owner, change it:

sudo chown yourusername:yourusername ~/.bash_history
carlin.scott
  • 105
  • 3
27

First type following command

shopt -s

to check weather histappend command is 'on' or 'off' If it is off then type following command to append history

history -a

If you want to save history with every new prompt run following command

export PROMPT_COMMAND='history -a'

For more information see this link

Chinmaya B
  • 7,022
  • 7
  • 27
  • 43