红联Linux门户
Linux帮助

Linux记录键盘操作

发布时间:2008-10-11 21:30:39来源:红联作者:Fedoraai
一个群友写的脚本,蛮经典的:

Linux记录键盘操作[code]# /bin/sh
# hist_record.sh
# This script is often to write in /etc/profile.
# This script could record history input and send mail to root.

RMIP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
TIME=`date +%Y%m%d.%H:%M.%S`

if [ "$RMIP" = "" ]
then
RMIP=`hostname`
fi

LOGS="/tmp/.hist/$TIME.$USER.$RMIP.hist"
HOST=`/bin/hostname`

if [ ! -d /tmp/.hist ]
then
mkdir /tmp/.hist
chmod 777 /tmp/.hist
fi

script -q $LOGS && mail -s "$TIME, $USER FROM $RMIP LOGIN $HOST" root < $LOGS[/code]
文章评论

共有 3 条评论

  1. kelre 于 2008-10-22 12:07:49发表:

    (5ty(

  2. Fedoranew 于 2008-10-12 00:23:57发表:

    就这么一点就可以了。。。?

  3. tarena 于 2008-10-11 21:57:35发表:

    强5:ty(