前言

创作开始时间:2021年6月27日17:00:12

如题,这里研究了一下ubuntu 的history这个指令,及其相关配置参数。

1、查看历史指令

history

# 或者
cat ~/.bash_history

都可以。

2、修改history的参数配置(自定义)

终端输入:sudo nano ~/.bashrc

找到其中内容:

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

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

改成:

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
#HISTCONTROL=ignoreboth

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
#HISTSIZE=1000
#HISTFILESIZE=2000
# 这个意思是不限制大小
HISTSIZE=-1
# 这个指不限制文件大小
HISTFILESIZE=-1
# 这个指保存到指定的文件,即:/home/ubuntu/history.txt
HISTFILE=/home/ubuntu/history.txt

保存,然后source ~/.bashrc 就大功告成!

以后都可以在/home/ubuntu/history.txt查看到历史指令。

小结

以上。

创作结束时间:2021年6月27日17:04:22

参考文献

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐