CODE:
PS1="`/usr/ucb/whoami`@`hostname`:"'[$PWD]'
# history
#USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
USER_IP=`who am i |awk '{print $6}' |sed -e 's/[()]//g' 2> /dev/null`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
if [ ! -d /tmp/.hist ]
then
mkdir /tmp/.hist
chmod 777 /tmp/.hist
fi
if [ ! -d /tmp/.hist/${LOGNAME} ]
then
mkdir /tmp/.hist/${LOGNAME}
chmod 300 /tmp/.hist/${LOGNAME}
fi
HISTSIZE=4096
export HISTSIZE
DT=`date "+%Y%m%d_%H%M%S"`
#HISTFILE="/tmp/.hist/${LOGNAME}/${USER_IP}.hist.$DT"
HISTFILE="/tmp/.hist/${LOGNAME}/$DT"
touch $HISTFILE
if [ -f $HISTFILE ];then
echo "user login time `date`" >> $HISTFILE
echo "USER_IP ${USER_IP}" >> $HISTFILE
fi
chmod 600 /tmp/.hist/${LOGNAME}/*.hist* 2>/dev/null
把这些东西加入到你的/etc/profile里面就好了。
这个东西在登录的时候会在你的/tmp/下面建立一个.hist的目录。每个用户使用什么ip地址和什么时间内连接上来的。都写在这个里面了。
这样比较方便查看别人干什么了