标签:shell批量创建用户
#!/bin/bash
for i in $(awk -F" " ‘{ print $2 }‘ user.list | sed ‘s/,/\n/g‘ | sort -u) ; do echo "groupadd $i" ; done
while read U_NAME G_NAME HOME_DIR
do
echo "mkdir $(dirname $HOME_DIR)"
echo "useradd -g $(echo $G_NAME | cut -d, -f1) -G $G_NAME -d $HOME_DIR $U_NAME"
echo "usermod -g $(echo $G_NAME | cut -d, -f1) -G $G_NAME -d $HOME_DIR $U_NAME"
done < user.list
while read U_NAME U_PASSWORD
do
if [ -z $U_PASSWORD ]
then
echo "echo \"1234\" | passwd --stdin $U_NAME"
else
echo "echo \"$U_PASSWORD\" | passwd --stdin $U_NAME"
fi
done < passwd.list
本文出自 “梦女孩” 博客,谢绝转载!
标签:shell批量创建用户
原文地址:http://dreamgirl1314.blog.51cto.com/1159474/1606115