解决方法:vim /etc/bashrc
在第一个case的else下面增加以下内容:
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 /root/dbasky ]
then
mkdir /root/dbasky
chmod 600 /root/dbasky
fi
if [ ! -d /root/dbasky/${LOGNAME} ]
then
mkdir /root/dbasky/${LOGNAME}
chmod 600 /root/dbasky/${LOGNAME}
fi
DT=`date "+%Y%m%d_%H%M%S"`
export PROMPT_COMMAND='{ date "+[ %Y%m%d %H:%M:%S `whoami` ] `history 1 | { read x cmd; echo "$cmd from ip:$SSH_CLIENT $SSH_TTY"; }`"; }>>/root/dbasky/${LOGNAME}/${USER_IP}dbasky.$DT'
chmod 600 /root/dbasky/${LOGNAME}/*dbasky* 2>/dev/null
保存退出就可以了。
多个帐户都用root 来登录 怎么看另一个用户使用的那些命令
精选 转载死里逃生 博主文章分类:Linux基本服务搭建
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
















