Linux的history命令
1、查看历史命令
[root@shell ~]# history
2、历史命令存放在哪个文件中?
~username/.bash_history
[root@shell ~]# ls /root/.bash_history
3、默认最多保存1000条历史命令
[root@shell ~]# set | grep -i hist BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
HISTCONTROL=ignoredups
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
4、清空历史命令
[root@rui ~]# history -c
5、设置历史查看格式
[root@rui ~]# HISTTIMEFORMAT=" %F %T `whoami`----"
[root@rui ~]# history
2 2017-02-23 15:32:04 root----history
3 2017-02-23 15:33:04 root----HISTTIMEFORMAT=" %F ----"
4 2017-02-23 15:33:09 root----history
5 2017-02-23 15:33:35 root----man HISTTIMEFORMAT
6 2017-02-23 15:37:38 root----HISTTIMEFORMAT=" %F %T `whoami`----"
7 2017-02-23 15:37:42 root----history
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。
文章标题:Linux的history命令
本文作者:wangzhirui
发布时间:2018-03-19, 16:36:52
最后更新:2025-02-27, 02:04:05
原始链接:https://wangzhirui.com/2018/03/19/Linux的history命令/转载请保留原文链接及作者。