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.

My bash history is working fine, except that it's too short.

HISTSIZE and HISTFILESIZE are set to 16k, yet I've only ever seen about 1000 entries in my history file. Currently the oldest command in it seems to be about a week old, which roughly coincides with my last reboot. It may be that the history file isn't surviving reboots. (This particular problem is mentioned in this question, but no solution is given)

Some relevant data:

.bash_history:
-rw------- 1 aib aib 10633 Mar 22 10:56 /home/aib/.bash_history
(~700 lines, oldest about a week ago)

.bashrc:
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=16384
HISTFILESIZE=16384

Nothing in /etc seems to mention .bash_history apart from apparmor (which I know next to nothing about.)

I run bash from Konsole (KDE's terminal) and rarely ever use tty1~6.

Edit: I've pinpointed an early entry's (#30) date and it's 10 days. My uptime is 11 days. It's very likely that my .bash_history file simply doesn't survive reboots.

Edit: I just did a reboot and my history file was preserved. So I can't duplicate the problem.

share|improve this question
    
It turned out that my history file was deleted on some reboots and I don't really remember whether I ever solved this or what the cause was if I did... I've since switched to zsh :) –  aib Oct 17 at 0:13

1 Answer 1

On my system I have created a /etc/profile.d/histsize.sh file with these two lines in it:

export HISTSIZE=10000

export HISTFILESIZE=2000000

Additionally I have replaced the two similar lines in .bashrc with the same two lines. The default .bashrc has these two lines:

HISTSIZE=1000
HISTFILESIZE=2000

Which I also replaced with:

export HISTSIZE=10000
export HISTFILESIZE=2000000

When updating .bashrc you have to remember to update it both in /etc/skel as well as in each home directory created before you updated /etc/skel/.bashrc

Since the above steps leaves so much room for mistakes, it is of course crucial to also have a backup.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.