首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

Linux上IP登录记录和操作记录

2012-11-14 
Linux下IP登录记录和操作记录PS1`whoami`@`hostname`:[$PWD]historyUSER_IP`who -u am i 2/dev/nul

Linux下IP登录记录和操作记录

PS1="`whoami`@`hostname`:"'[$PWD]'historyUSER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`if [ "$USER_IP" = "" ]thenUSER_IP=`hostname`fiif [ ! -d /tmp/history ]thenmkdir /tmp/historychmod 777 /tmp/historyfiif [ ! -d /tmp/history/${LOGNAME} ]thenmkdir /tmp/history/${LOGNAME}chmod 300 /tmp/history/${LOGNAME}fiexport HISTSIZE=4096DT=`date +"%Y%m%d_%H%M%S"`export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP} history.$DT"chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
?

热点排行