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:

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

shopt -s histappend

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.

  • 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 '14 at 0:13

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:


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.

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.