[PowerShell] 按时间和登录IP记录Linux所有用户操作日志的脚本 →→→→→进入此内容的聊天室

来自 , 2021-04-05, 写在 PowerShell, 查看 186 次.
URL http://www.code666.cn/view/b25b911f
  1.  
  2. PS1="`whoami`@`hostname`:"'[$PWD]'
  3. history
  4. USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
  5. if [ "$USER_IP" = "" ]
  6. then
  7. USER_IP=`hostname`
  8. fi
  9. if [ ! -d /tmp/history ]
  10. then
  11. mkdir /tmp/history
  12. chmod 777 /tmp/history
  13. fi
  14. if [ ! -d /tmp/history/${LOGNAME} ]
  15. then
  16. mkdir /tmp/history/${LOGNAME}
  17. chmod 300 /tmp/history/${LOGNAME}
  18. fi
  19. export HISTSIZE=4096
  20. DT=`date +"%Y%m%d_%H%M%S"`
  21. export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP} history.$DT"
  22. chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
  23.  
  24. //shell/5375

回复 "按时间和登录IP记录Linux所有用户操作日志的脚本"

这儿你可以回复上面这条便签

captcha