1)查看历史命令
[root@shell ~]# history
2)历史命令存放在哪个文件中?
~username/.bash_history
[root@shell ~]# ls /root/.bash_history
默认最多保存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
3)清空历史命令
[root@rui ~]# history -c
4) 设置历史查看格式
[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
转载于:https://www.cnblogs.com/ruigu/p/8603176.html