Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The command history between sessions is not getting saved. I'm using guake and the history for the session is working fine.

I noticed that .bash_history had some commands I executed in sudo -s mode and tried the same again and all the commands while in the session got saved so I tried chmod 777 .bash_history

Now the old commands appear at the start of a session but no new commands are getting saved

Thanx in advance

share|improve this question
2  
So... what exactly are you trying to accomplish? You dont seem to be asking a question here :/ –  Thomas W. Mar 19 '11 at 14:06
4  
Mode 777 is unnecessary, it has especially nothing to do with the 'executable' flag (the default mode is 600). The ~/.bash_history gets written when you log out (to reach the newer commands you can use the history command). But i fail to see the problem too.. –  Onedinkenedi Mar 19 '11 at 14:52

4 Answers 4

The commands are not visible because Bash saves history to the .bash_history file only after the shell quits, and this happens very rarely with Guake. There is a simple workaround to make Bash append the history (instead of overwriting the file) after every command

shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
share|improve this answer
1  
Pure awesome. Wish I had known about this 5 years ago. –  HDave Aug 13 '12 at 18:43

See http://mywiki.wooledge.org/BashFAQ/088 for how to avoid losing history lines, and an explanation of the side-effects of doing so.

share|improve this answer

Related, typically how this gets broken is if you sudo a command before you have a .bash_history file, as then it'll get created owned by root instead of your user.

share|improve this answer
    
Good answer, was my problem –  Cookie Mar 14 at 10:07

It could also be that root:root owns your .bash_history (ROOT SHOULDN'T BE THE OWNER, YOUR USER SHOULD BE THE OWNER!), in that case you need to:

#chown user:user .bash_history

This apparently could happen if you do sudo bash alot!

share|improve this answer

Your Answer

 
discard

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