Ubuntu 中历史记录的默认大小是 1000,但它太小了。我想把它改成 10000,所以我追加
export HISTSIZE=10000
export HISEFILESIZE=10000
Run Code Online (Sandbox Code Playgroud)
到.profile
和“源”这
source .profile
Run Code Online (Sandbox Code Playgroud)
然后我跑
echo $HISTSIZE
echo $HISTFILESIZE
Run Code Online (Sandbox Code Playgroud)
两者都显示 1000,但我重新启动计算机,它变为“默认”。为什么不起作用?
Pau*_*aul 92
我尝试了同样的事情,只是发现偷偷摸摸的 Ubuntu~/.bashrc默认设置了这些变量,它被执行而不是~/.profile用于非登录 shell,例如只打开一个终端窗口。更改这些行为~/.bashrc我修复了它:
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
Run Code Online (Sandbox Code Playgroud)
Pai*_*ser 57
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).
Run Code Online (Sandbox Code Playgroud)
所以对于一个无限的历史列表,使:
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.
Run Code Online (Sandbox Code Playgroud)
所以对于一个无限的.bash_history 历史文件,制作:
HISTFILESIZE=(some number less than 0 )
正如@Michal Przybylowicz所提到的,这些文件有时似乎在 Xubuntu(和 Lubuntu)中被忽略。如果是这样,您可以改为写行
Run Code Online (Sandbox Code Playgroud)export HISTSIZE=10000 export HISTFILESIZE=10000
到/etc/bash.bashrc。这将全局更改这些环境变量的值。
| 归档时间: |
|
| 查看次数: |
121861 次 |
| 最近记录: |