shell编程-添加用户-删除用户

本文介绍了如何在Shell中进行批量删除用户的操作,包括遇到的命令错误问题及正确的修改方法。
摘要由CSDN通过智能技术生成
  • https://blog.51cto.com/1208073155/1532560
    在这里插入图片描述
read -t 30 -p "Please input your user name:  " nam
read -t 30 -p "Please input your the number of users: " numb
read -t 30 -p "Please input your password for the users: " pss
if [ ! -z "$nam"  -a  ! -z "$numb" -a ! -z "$pss" ]
        then
        y=$(echo $numb | sed 's/[0-9]//g')
        if [ -z "$y" ]
        then
        for (( i=0;i<$numb;i=i+1))
                do
                        /usr/sbin/useradd $nam$i
                        echo $pss | passwd  $nam$i
                done
        fi
fi

[root@localhost shelltest]# echo finley333 | passwd yang17
Changing password for user yang17.
New password: Retype new password: Password change aborted.
New password: Password change aborted.
New password: Password change aborted.
passwd: Have exhausted maximum number of retries for service
[root@localhost shelltest]# ./addu.sh 
Please input your user name:  lin
Please input your the number of users: 8
Please input your password for the users: Finley520
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
passwd: bad argument --sdtin: unknown option
[root@localhost shelltest]# vim addu.sh 
[root@localhost shelltest]# echo finley333 | passwd --sdtin yang17
passwd: bad argument --sdtin: unknown option
[root@localhost shelltest]# vim addu.sh 
[root@localhost shelltest]# ./addu.sh 
Please input your user name:  linj
Please input your the number of users: 20
Please input your password for the users: feng5258520
Changing password for user linj0.
New password: Retype new password: Password change aborted.
New password: Password change aborted.
New password: Password change aborted.
passwd: Have exhausted maximum number of retries for service
Changing password for user linj1.
New password: Retype new password: Password change aborted.
New password: Password change aborted.
New password: Password change aborted.
passwd: Have exhausted maximum number of retries for service
Changing password for user linj2.
New password: Retype new password: Password change aborted.
New passwor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值