linux history 记录 时间 ip 登录用户

vi /etc/profile



#history

USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ -z $USER_IP ]
then
USER_IP=`hostname`

fi

export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S] [${USER_IP}-${LOGNAME}]"

source /etc/profile


history

效果

  999  [2016.08.18 09:48:06] [10.1.193.116-root]ll
 1000  [2016.08.18 09:48:19] [10.1.193.116-root]find / -name .bashrc
 1001  [2016.08.18 10:22:36] [10.1.193.116-root]more /etc/profile
 1002  [2016.08.18 10:22:45] [10.1.193.116-root]                 vi /etc/profile
 1003  [2016.08.18 10:22:55] [10.1.193.116-root]more /etc/profile
 1004  [2016.08.18 10:23:00] [10.1.193.116-root]                 vi /etc/profile
 1005  [2016.08.18 10:27:16] [10.1.193.116-root]                 vi -r /etc/profile
 1006  [2016.08.18 10:29:12] [10.1.193.116-root]source /etc/profile
 1007  [2016.08.18 10:29:20] [10.1.193.116-root]more /etc/profile
 1008  [2016.08.18 10:29:24] [10.1.193.116-root]       history
 1009  [2016.08.18 10:29:50] [10.1.193.116-root]more /etc/profile
 1010  [2016.08.18 10:44:30] [10.1.193.116-root]vi /etc/profile
 1011  [2016.08.18 10:46:35] [10.1.193.116-root]ll
 1012  [2016.08.18 10:47:04] [10.1.193.116-root]history
 1013  [2016.08.18 10:47:13] [10.1.193.116-root]source /etc/profile
 1014  [2016.08.18 10:47:16] [10.1.193.116-root]history
 1015  [2016.08.18 10:47:46] [10.1.193.116-root]ll
 1016  [2016.08.18 10:47:49] [10.1.193.116-root]soft
 1017  [2016.08.18 10:47:49] [10.1.193.116-root]ll
 1018  [2016.08.18 10:47:52] [10.1.193.116-root]cd soft
 1019  [2016.08.18 10:47:53] [10.1.193.116-root]ll
 1020  [2016.08.18 10:48:27] [10.1.193.116-root]history
 1021  [2016.08.18 10:57:47] [10.1.193.116-root]more /etc/profile
 1022  [2016.08.18 10:57:55] [10.1.193.116-root] #history
 1023  [2016.08.18 10:57:55] [10.1.193.116-root]USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
 1024  [2016.08.18 10:57:55] [10.1.193.116-root]if [ -z $USER_IP ]; then USER_IP=`hostname`; fi
 1025  [2016.08.18 11:00:25] [10.1.193.116-root]export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S] [${USER_IP}-${LOGNAME}]"
 1026  [2016.08.18 11:00:27] [10.1.193.116-root]history


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值