Linux--用history查看历史命令
文章目录
history 用法汇总
命令 | 用法 |
---|---|
history |
列出全部历史命令 |
history 数字# |
列出最近的#条命令 |
history -c |
将目前shell中的所有history命令消除【就是按↑翻不到了】,对命令历史文件没有影响 |
history -w |
将本次登录的命令写入命令历史文件中, 默认写入~/.bash_history【其实是会自动保存的】 |
history -r |
将命令历史文件中的内容读入到目前shell的history记忆中【就是按↑能翻到】 |
注:~/.bash_history文件会自动保存当前用户使用过的历史命令
history——列出全部历史命令
history 数字#——列出最近的#条命令
history -c——将目前shell中的所有history命令消除,对命令历史文件没有影响
history -w——将本次登录的命令写入命令历史文件中, 默认写入~/.bash_history
history -r——将命令历史文件中的内容读入到目前shell的history记忆中
先history -c
——将目前shell中的所有history命令消除,会发现按↑翻不到历史命令
再history -r
——将命令历史文件中的内容读入到目前shell的history记忆中,会发现按↑可以翻到历史命令