history命令的使用方法

如果你经常使用Linux命令,那么使用history命令无疑会提升你的工作效率。

History命令主要用于显示历史指令记录内容, 下达历史纪录中的指令 。

1>History命令语法:

[test@linux]# history [n]
[test@linux]# history [-c]
[test@linux]# history [-raw] histfiles
参数:
n   :数字,要列出最近的 n 笔命令列表
-c  :将目前的shell中的所有 history 内容全部消除
-a  :将目前新增的history 指令新增入 histfiles 中,若没有加 histfiles ,
则预设写入 ~/.bash_history
-r  :将 histfiles 的内容读到目前这个 shell 的 history 记忆中
-w  :将目前的 history 记忆内容写入 histfiles

Linux系统当你在shell(控制台)中输入并执行命令时,shell会自动把你的命令记录到历史列表中,一般保存在用户目录下的.bash_history文件中。默认保存1000条,你也可以更改这个值。

猜你喜欢

转载自liuna718-163-com.iteye.com/blog/2409168