关键词:id、useradd
- id:检查系统用户是否存在
- useradd:添加用户
脚本:
#!/bin/bash echo "正在批量创建用户" read -p "pleace input password:" PASSWD for UNAME in $(cat /root/tansk/user.txt) do echo "user name is:" $UNAME id $UNAME &>/dev/null if [ $? -eq 0 ]; then echo "user exist" else sudo useradd $UNAME &>/dev/null echo $PASSWD| passwd --stdin $UNAME &>/dev/null fi done
来源:https://www.cnblogs.com/tanshouke/p/12405287.html