標籤:linux shell 程式設計語言
linux系統-shell編程-幾個shell指令碼一 滅掉使用者 killuser.sh#!/bin/sh
# The script to kill login user
user_name="$1"
/bin/ps aux | /bin/grep $user_name | /bin/awk `{ print $2 }` > /tmp/temp.pid
kill_id=`cat /tmp/temp.pid`
for PID in kill_id
do
/bin/kill -9 $PID 2> /dev/null
done
二 大量新增使用者useradd.sh#/bin/sh
echo "input name"
read name
echo "input num"
read num
n=1
while [ $n -le $num ]
do
/usr/bin/useradd $name$n
n=`expr $n + 1`
done
echo "please input the passwd"
read passwd
m=1
while [ $m -le $num ]
do
echo $passwd | /usr/bin/passwd --stdin $name$m
m=`expr $m + 1`
done
三 檢查系統的SetUID setuid.sh#!/bin/sh
mkdir /backup
/usr/bin/find / -perm -4000 -o -2000 > /tmp/setuid.check 2> /dev/null
for file in `/bin/cat /tmp/setuid.list > /dev/null`
do
/bin/grep $file /backup/setuid.list > /dev/null
if [ "#? != "0" ]
then
echo "$file is not in list"
fi
done
/bin/rm /tmp/setuid.check
附:my_qq 872785786 及linux系統基礎相應的網盤資料連結:http://pan.baidu.com/s/1ydewA 密碼:kaek
歡迎一起交流學習-安卓嵌入式開發,若想免費擷取更多資料,請聯絡我即可-共用精神,提供1000G+的技術資料
ios,安卓,嵌入式,及各種程式設計語言
linux系統-shell編程-幾個shell指令碼