linux系統-shell編程-幾個shell指令碼

來源:互聯網
上載者:User

標籤: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指令碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.