如何永远改变历史规模?

Ubuntu中历史记录的默认大小是1000,但它太小了。 我想将它改为10000,所以我追加

export HISTSIZE=10000 export HISEFILESIZE=10000 

to .profile和’source’它

 source .profile 

然后我跑了

 echo $HISTSIZE echo $HISTFILESIZE 

两者都显示了1000但我重新启动计算机它’默认’。 为什么不起作用?

我尝试了同样的事情,只是发现偷偷摸摸的Ubuntu默认在~/.bashrc设置这些变量,对于非登录shell(例如只打开终端窗口)执行而不是~/.profile 。 更改~/.bashrc这些行为我修复了它:

 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000 

从Bash参考手册 :

 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). 

因此,对于无限历史列表 ,请:
HISTSIZE =(某些数字小于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. 

因此,对于无限的.bash_history 历史文件 ,make:
HISTFILESIZE =(某些数字小于0

正如@Michal Przybylowicz所提到的,这些文件似乎有时会被Xubuntu(和Lubuntu)忽略。 如果是这样,你可以改为写行

 export HISTSIZE=10000 export HISEFILESIZE=10000 

/etc/bash.bashrc