歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> 限制單用戶登陸

限制單用戶登陸

日期:2017/3/6 15:25:17   编辑:關於Unix
因公司的erp連線數量有限,需限制用戶每人只能有一個連線. 就寫了一個shell. 在/etc/profile中的最後一行加入以下內容: /home/root/limit_user.sh 以下為shell的內容: # more limit_user.sh #!/bin/ksh ########### search1=`who -m|awk 'print '` limit_user= 因公司的erp連線數量有限,需限制用戶每人只能有一個連線.
就寫了一個shell.

在/etc/profile中的最後一行加入以下內容:
/home/root/limit_user.sh

以下為shell的內容:

# more limit_user.sh
#!/bin/ksh

###########
search1=`who -m|awk '{print }'`
limit_user=`grep "$" /home/root/limit_user.lst | grep -v grep | wc | awk '{print }'`
no=`who | awk '{print }'|grep -w "$" | wc -l`
if [ $limit_user -eq 1 -a $no -ge 2 ]    #在這裡,如果將2改為3,則表示每個用戶可以有2個登陸,最多有兩個,以此類推.
then
echo 'this user only can login once,please conncet your admin'
sleep 2
exit 1
fi
echo "login system suclearcase/" target="_blank" >ccess"
###########


將用戶列表寫入到/home/root/limit_user.lst文件中,每個用戶一行.
如果用戶名不在limit_user.lst中出現,則此用戶是不受此限制的.
以上在aix中測試通過.


Copyright © Linux教程網 All Rights Reserved