#首先我们需要创建一个xxx.txt文件,把需要的我们创建的用户写在这个文本里面来,注意:每写完一个用户都需要换行。
vim doutinhao.txt
sudaqiang
sumingzhe
sumingcheng
sumingyu
#创建一个xxx.sh shell 脚本,然后用for循环把创建的xxxx.txt遍历出来,以下为shell脚本:
#!/bin/bash
#我这里是把shell脚本和txt文件创建在同一个目录下,如果不在同个目录下,请注意下路径
for user in cat xxxx.txt
do
useradd $user
#这里的passwd --stdin 的意思:是非交互,直接输入密码
echo “123456” | passwd --stdin $user
echo “The user useradd success !”
done