Linux的history命令

1、查看历史命令

1
[root@shell ~]# history

2、历史命令存放在哪个文件中?

1
2
~username/.bash_history
[root@shell ~]# ls /root/.bash_history

3、默认最多保存1000条历史命令

1
2
3
4
5
6
[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、清空历史命令

1
[root@rui ~]# history -c

5、设置历史查看格式

1
2
3
4
5
6
7
8
[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
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×