zoukankan      html  css  js  c++  java
  • 一种监控全部账户登陆及操作命令的方法

    公司师兄教的一种方法:

    将例如以下脚本,增加到/etc/profile最后就可以
     
    PS1="`whoami`@`hostname`:"'[$PWD]'
    history
    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 /tmp/history ]
    then
    mkdir /tmp/history
    chmod 777 /tmp/history
    fi
    if [ ! -d /tmp/history/${LOGNAME} ]
    then
    mkdir /tmp/history/${LOGNAME}
    chmod 300 /tmp/history/${LOGNAME}
    fi
    export HISTSIZE=4096
    DT=`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

    
  • 相关阅读:
    10.28作业
    10.27作业
    10.26作业
    10.22作业
    10.20作业
    10.19作业
    10.16作业
    10.15作业
    10.14作业
    10.13作业
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4198184.html
Copyright © 2011-2022 走看看