作者:javalee要想让某些用户不能
系统,可以用简单实现
可以先建立一个deny.user的
,内容如下:user1
user2
user3
然后将下列代码加到 /etc/porfile里
logname=`whoami |grep '{print $1}'`
while read i; do
if [ $i =$logname ]; then
echo "Sorry,$LOGNAME can not " && exit
fi
do < /path/deny.user
代码:
#! /bin/ksh
#scriptname:killuser
#disabel some user login system
#start...
echo -n "who do you want to kill:"
read username
while true
do
kill -9 $(ps -aux|grep $username|awk '{print $2}')
sleep 1
done
javalee//home>su abc //用户abc登录成功Password:
abc//home>
root//home/javalee/lx>sh killuser //运行
who do you want to kill:abc
...
javalee//home>su abc //运行脚本后,被KILL
Password:
abc//home>Killed
javalee//home> //登录失败,返回
阅读(943) | 评论(0) | 转发(0) |