Monday, March 9, 2009

050 通过HISTTIMEFORMAT在命令行中显示时间戳

通常当你在命令行中键入history命令,会显示以往执行的命令。但是为了审计的需要,如果能够显示命令执行的时间戳就非常有用了:
# export HISTTIMEFORMAT=’%F %T ’

# history | more
1 2008-08-05 19:02:39 service network restart
2 2008-08-05 19:02:39 exit
3 2008-08-05 19:02:39 id
4 2008-08-05 19:02:39 cat /etc/redhat-release

注意,你也可以通过设置下面的别名来方便的使用history命令:
alias h1='history 10' 
alias h2='history 20'
alias h3='history 30'

No comments:

Post a Comment