How to change history size for ever?
The default size of history in Ubuntu is 1000 but it's too small. I want to change it to 10000, So I append
export HISTSIZE=10000
export HISEFILESIZE=10000
to .profile
and 'source' it
source .profile
then I run
echo $HISTSIZE
echo $HISTFILESIZE
1000 was displayed for both but I reboot my computer it went 'default'. Why doesn't it work?
Solution 1:
I tried the same thing, only to discover that sneaky Ubuntu sets these variables in ~/.bashrc
by default, which is executed instead of ~/.profile
for non login shells such as just opening a terminal window. Changing these lines in ~/.bashrc
fixed it for me:
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
Solution 2:
From the Bash Reference Manual:
HISTSIZE
The maximum number of commands to remember on the history list.
If the value is 0,
**commands are not saved** in the history list.
Numeric values less than zero result in
every command being saved on the history list (there is no limit).
So for an infinite history list, make:
HISTSIZE=(some number less than 0)
HISTFILESIZE
The maximum number of lines contained in the history file.
When this variable is assigned a value,
the history file is truncated, if necessary,
to contain no more than that number of lines
by removing the oldest entries.
The history file is also truncated to this size after
writing it when a shell exits.
If the value is 0,
**the history file is truncated to zero size.**
Non-numeric values and numeric values less than zero
inhibit truncation.
So for an infinite .bash_history
history file, make:
HISTFILESIZE=(some number less than 0)
Solution 3:
As mentioned by @Michal Przybylowicz, these files seem to be ignored in Xubuntu (and Lubuntu) sometimes. If so, you could instead write the lines
export HISTSIZE=10000 export HISTFILESIZE=10000
to /etc/bash.bashrc
. This will change these environment variables' values globally.