首页 > 系统服务 > 详细

Linux history时间用户ip设置

时间:2016-06-24 14:23:54      阅读:114      评论:0      收藏:0      [点我收藏+]

Linux history时间用户ip设置

 
     在使用linux服务器的时候发生一些不知道谁操作的问题,google一下说history命令可以查看到历史记录,用过之后发现还是不够详细,再google,原来可以自己设置history的显示。
 
1.用vi编辑器打开/etc/profile
2.最后加两句代码
 
USER_IP=`who -u am i 2>/dev/null| awk ‘{print $NF}‘|sed -e ‘s/[()]//g‘`  
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "  
 
3.source /etc/profile
4.执行history
     显示如下:
    1000  [2012-09-08 04:05:09][root][192.168.10.136] history
     1001  [2012-09-08 04:14:24][root][192.168.10.136] cd root
     1002  [2012-09-08 04:14:27][root][192.168.10.136] ls
     1003  [2012-09-08 04:14:30][root][192.168.10.136] cd /opt

Linux history时间用户ip设置

原文:http://www.cnblogs.com/carbon3/p/5613790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!