1. Cat ~/.bash_history
2. History | More
Enter the keyboard----------line
Space Keyboard---------------one page
3,! 103 Execution of 103th order
Problem
In the process of using bash, we may want to .bash_history
document more useful historical commands, so that we can query later, and here's a workaround.
Change the default history
> vi ~/.bashrc# 添加# 忽略[连续]重复命令HISTCONTROL=ignoredups# 清除重复命令# HISTCONTROL=erasedups# 忽略特定命令HISTIGNORE="[ ]*:ls:ll:cd:vi:pwd:sync:exit:history*"# 命令历史文件大小10MHISTFILESIZE=1000000000# 保存历史命令条数10WHISTSIZE=1000000
The above configuration can be done by set | grep HIST
Viewing the options.
Multi-terminal Append
When multiple terminals are opened and one of the terminals is closed, the command history of the other terminals is overwritten, where we use the Append method to avoid overwriting the command history file .bash_history
. Open ~/.bashrc
the file again to add the following sentence.
> vi ~/.bashrc# 添加shopt -s histappend
More shopt
options can be echo $SHELLOPTS
viewed by command.
Effective ¶
source ~/.bashrc`
or close the bash terminal and reopen it.
If you need to use VI mode in bash to speed up your input, check this article to Open Bash VI mode
After a while, you'll be able to take a ~/.bash_history
file and admire the commands you've been knocking over.
enjoy!
Linux Modified history