Hack 50. Display TIMESTAMP in history using HISTTIMEFORMAT
by Ramesh
Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timestamp along with the command as shown below.
- # 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
Note: You can also setup the following alias to view the recent history commands.
- alias h1='history 10'
- alias h2='history 20'
- alias h3='history 30'
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .