批量创建用户脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量创建用户脚本相关的知识,希望对你有一定的参考价值。
[[email protected] scripts]# cat useradd.sh
#!/bin/sh
#editor tangbo
#QQ 79313760
################start#########################
USERS_INFO=/root/addusers.txt
USERADD=/usr/sbin/useradd
PASSWD=/usr/bin/passwd
CUT=/bin/cut
while read LINES
do
USERNAME=`echo $LINES | $CUT -f1 -d ‘ ‘`
PASSWORD=`echo $LINES | $CUT -f2 -d ‘ ‘`
$USERADD $USERNAME
if [ $? -eq 0 ]
then
echo "$USERNAME exists,skip set password"
else
echo $PASSWORD | $PASSWD --stdin $USERNAME > /dev/null 2>&1
fi
done < $USERS_INFO
###########################end######################################
[[email protected] ~]# cat addusers.txt
bebepay201501 password201501
bebepay201502 password201502
bebepay201503 password201503
bebepay201504 password201504
bebepay201505 password201505
bebepay201506 password201506
bebepay201507 password201507
bebepay201508 password201508
bebepay201509 password201509
bebepay201510 password201510
bebepay201511 password201511
[[email protected] ~]#
本文出自 “山猫” 博客,谢绝转载!
以上是关于批量创建用户脚本的主要内容,如果未能解决你的问题,请参考以下文章