亚洲国产第一_开心网五月色综合亚洲_日本一级特黄特色大片免费观看_久久久久久久久久免观看

Hello! 歡迎來(lái)到小浪云!


Centos記錄所有登陸用戶的IP操作日志



將以下代碼添加到/etc/profile文件底部

history  USER=`whoami`  USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`  if [ "$USER_IP" = "" ]; then  USER_IP=`hostname`  fi  if [ ! -d /var/log/history ]; then  mkdir /var/log/history  chmod 777 /var/log/history  fi  if [ ! -d /var/log/history/${LOGNAME} ]; then  mkdir /var/log/history/${LOGNAME}  chmod 300 /var/log/history/${LOGNAME}  fi  export HISTSIZE=4096  DT=`date +"%Y%m%d_%H:%M:%S"`  export HISTFILE="/var/log/history/${LOGNAME}/${USER}@${USER_IP}_$DT"  chmod 600 /var/log/history/${LOGNAME}/*history* 2>/dev/NULL

 

添加保存以后執(zhí)行source /etc/profile(或者. /etc/profile)使其生效。

之后效果是會(huì)記錄每個(gè)登錄用戶的操作命令,登錄時(shí)間,日志存放在 “/var/log/history/用戶名” 目錄下,每次用戶退出登陸后會(huì)生成日志,可供查閱。

相關(guān)閱讀