Linux用戶歷史記錄

能夠保存每一個用戶登陸後的全部操做
ide

PS1="`whoami`@`hostname`:"'[$PWD]'it

historyclass

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

if [ "$USER_IP" = "" ]登錄

thensed

USER_IP=`hostname`date

fidi

if [ ! -d /tmp/hist ]view

thenvi

mkdir /tmp/hist

chmod 777 /tmp/hist

fi

if [ ! -d /tmp/hist/${LOGNAME} ]

then

mkdir /tmp/hist/${LOGNAME}

chmod 300 /tmp/hist/${LOGNAME}

fi

export HISTSIZE=4096

DT=`date "+%Y-%m-%d_%H:%M:%S"`

export HISTFILE="/tmp/hist/${LOGNAME}/${USER_IP} hist.$DT"

chmod 600 /tmp/hist/${LOGNAME}/*hist* 2>/dev/null