1\
------------------------------
#!/bin/bash
#automating user creation
for x in $(seq 1 10); do
echo adding test$x
(
echo -ne "test$x\t"
useradd test$x 2>&1 >/dev/null && passwd test123$x
) >> /tmp/userlog
done
echo 'cat /tmp/userlog to see new passwords'
---------------------------------------
2\
------------------------------------
a\create a file called /home/student/userlist,which contains the username you are about to create.
=======
linsco
uxci
jxzengqinghua
test
roderick
=========
#!/bin/bash
#Script for creating all users defined in the file
#/home/student/userlist
for NAME in $(cat /home/student/userlist)
do
/user/sbin/useradd $NAME
PASSWORD=$(openssl rand -base64 10)
echo $PASSWORD |passwd --stdin $NAME
echo "username:$NAME,password:$PASSWORD"|
mail -s "Account Info" root@example.com
done
-----------------------------------------
阅读(486) | 评论(0) | 转发(0) |