1.从键盘读取用户名和需要创建的数量,批量添加,密码等同用户名
- #!/bin/bash
-
read -p "Please enter the username and how many would you create:" a b
-
for ((i=1;i<=$b;i++))
-
do useradd -m $a$i && echo "$a$i:$a$i">lst && chpasswd
-
done
-
rm -rf lst
2.读取文件中的用户列表,批量添加
- #!/bin/bash
-
for name in `more list`
-
do
-
if [ -n "$name" ]
-
then
-
useradd -m "$name" && echo $name | passwd --stdin "$name" && echo "User $name createed!“
-
fi
-
done
阅读(1569) | 评论(0) | 转发(0) |