Linux history配置时间戳、执行用户

history配置时间戳格式,极其哪个用户执行了命令。

    设置很简单:


[root@web01 /]# history
    4  ./startup.sh
    5  ./shutdown.sh
    6  ps -ef
    7  ./startup.sh
    8  ls
    9  cd /home
   10  ls
   11  cd mnt
   12  cd /mnt
   13  ls
   14  ls /usr/local/tomcat-server/
   15  cd /usr/local/tomcat-server/
   16  ls
   17  cd logs/
   18  ls
   19  cd ..
   20  cd ./
   21  cd ../
   22  ls
   23  cd ./
   24  cd /jome
   25  cd ./home
   26  cd home
   27  cd /home
   28  cd ..

   29  ls


设置方法:
[root@web01 /]# export HISTTIMEFORMAT="%F %T `whoami` "

[root@web01 /]# echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile

**************************************

  965  2013-10-18 10:32:34 root cd ..
  966  2013-10-18 10:32:34 root ls
  967  2013-10-18 10:32:34 root hostname -d
  968  2013-10-18 10:32:34 root hostname -f
  969  2013-10-18 10:32:34 root ipconfig
  970  2013-10-18 10:32:34 root iwconfig
  971  2013-10-18 10:32:34 root ls
  972  2013-10-18 10:32:34 root ls
  973  2013-10-18 10:32:34 root cd ..
  974  2013-10-18 10:32:34 root ls
  975  2013-10-18 10:32:34 root cd usr/local/tomcat-server/
  976  2013-10-18 10:32:34 root ls
  977  2013-10-18 10:32:34 root cd logs/
  978  2013-10-18 10:32:34 root ls
  979  2013-10-18 10:32:34 root tail -f catalina.out
  980  2013-10-18 10:32:34 root cd ../
  981  2013-10-18 10:32:34 root cd /usr/local
  982  2013-10-18 10:32:34 root ls
  983  2013-10-18 10:32:34 root cd tomcat-server/
  984  2013-10-18 10:32:34 root cd logs
  985  2013-10-18 10:32:34 root ls
  986  2013-10-18 10:32:34 root tail -f catalina.out
  987  2013-10-18 10:32:34 root ping 192.168.5.210
  988  2013-10-18 10:32:34 root cd ..
  989  2013-10-18 10:32:34 root ls
  990  2013-10-18 10:32:34 root exit
  991  2013-10-18 10:32:34 root ls
  992  2013-10-18 10:32:34 root cd
  993  2013-10-18 10:32:34 root ls
  994  2013-10-18 10:32:34 root cd ..
  995  2013-10-18 10:32:34 root ls
  996  2013-10-18 10:32:34 root cd usr/local/tomcat-server/
  997  2013-10-18 10:32:34 root sl
  998  2013-10-18 10:32:34 root ls
  999  2013-10-18 10:32:35 root cd ..
 1000  2013-10-18 10:32:36 root lks
 1001  2013-10-18 10:32:37 root ls
 1002  2013-10-18 10:33:15 root histroy
 1003  2013-10-18 10:33:24 root history
 1004  2013-10-18 10:40:23 root export HISTTIMEFORMAT="%F %T `whoami` "
 1005  2013-10-18 10:40:34 root echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile
 1006  2013-10-18 10:40:36 root history


     HISTTIMEFORMAT 的格式就是 strftime 函数的格式,比如上面的  "%F %T",%F 表示显示出 Y-M-D 格式的日期,%T 表示显示出  H-M-S 这样格式的时间。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值