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

  • did you figure this out? if not, paste your profile/rc here for review.
    – JBallin
    Jun 18, 2018 at 19:03

2 Answers 2


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
  • 4
    Worked for me. Curious how that happened though.
    – Klik
    Jan 8, 2015 at 22:32
  • 3
    Same here. I also wonder why that happened?
    – Chris
    Apr 7, 2015 at 20:49
  • 1
    Shouldn't you set the group as well, with sudo chown yourusername:yourusername ~/.bash_history? Nov 17, 2017 at 21:35
  • Boombaa ! I take this moral from the story: "When such basic facility fails (and by default is ON), then most likely this is due to famous "permissions: problem." :)
    – Peter
    Nov 12, 2018 at 15:46
  • This fixed the problem for me too. I strongly suspect that sudo -s was the problem but it does not happen every time. I note that -s leaves the home dir as the original. I was using that before my history vanished. May 13, 2020 at 21:15

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

  • histappend is 'on'. Can't figure out what's going on. :/
    – Deepal
    Jul 18, 2014 at 8:31
  • I think some pipe connecting to history file is broken ,because if from terminal history is append then only it can be case of broke pipe try reparing or reinstalling system if you can
    – Chinmaya B
    Jul 18, 2014 at 8:52
  • 1
    histappend isn't even listed in the output of shopt -s even tho $HISTSIZE and $HISTFILESIZE are set properly. Idea? Thanks!
    – HCSF
    Oct 16, 2019 at 0:29

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.