码迷,mamicode.com
首页 > 系统相关 > 详细

linux系统-shell编程-几个shell脚本

时间:2015-04-19 08:55:54      阅读:166      评论:0      收藏:0      [点我收藏+]

标签: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脚本

标签:linux   shell   编程语言   

原文地址:http://blog.csdn.net/qq_22075977/article/details/45126057

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!