Chinaunix首页 | 论坛 | 博客
  • 博客访问: 71586
  • 博文数量: 9
  • 博客积分: 214
  • 博客等级: 入伍新兵
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-09 13:24
个人简介

hi,fuck u

文章分类
文章存档

2011年(9)

我的朋友

分类: LINUX

2011-10-14 10:01:59

      1 #!/bin/bash
      2
      3 #it is for root to change shell for users
      4 #wrote by badboy  2011.10.9
      5
      6 echo
      7 echo "####### It is for root to change users'shell ########"
      8 echo
      9 echo "####             Wrote by badboy                #####"
     10 echo "#####################################################"
     11 echo "##   for example : user=root shell=/bin/bash       ##"
     12 echo "#####################################################"
     13 read -p " enter the user name :" USER
     14 read -p " enter the shell for $USER :" SHELL
     15
     16 ######### to see if the user exit
     17
     18 if grep $USER /etc/passwd  1> /dev/null
     19   then
     20      echo
     21   else
     22       echo "System does not exit the user"
     23       exit
     24 fi
     25
     26 OIFS=$IFS
     27 IFS=:
     28 cat /etc/passwd |  while  read a b c d e f  OLDSHELL
     29                                 do
     30                                      if [ $a = $USER ]
     31                                         then
     32                                   echo "$a:$b:$c:$d:$e:$f:$SHELL" >>/etc/passwd.old
     33                                          else
     34                                 echo "$a:$b:$c:$d:$e:$f:$OLDSHELL" >>/etc/passwd.old
     35                                      fi
     36                                 done
     37 IFS=$OIFS
     38 cp /etc/passwd /etc/passwd.`date %y%m%d` #备份passwd
     39 cat /etc/passwd.old >/etc/passwd && cat /dev/null >/etc/passwd.old
阅读(3283) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~