第一种方法:
[[email protected] ~]# echo stu{01..10}|tr " " "\n"|sed -r ‘s#(.)#useradd \1;pass=$((RANDOM+10000000));echo "$pass"|passwd --stdin \1;echo -e "\1\techo "$pass"
">>/tmp/oldboy.log#g‘|bash
第二种方法:
echo stu{01..10}|xargs -n1|sed -n ‘s#.#useradd & \&\& echo $RANDOM|md5sum|cut -c5-9 >>/tmp/mima.log \&\& echo "tail -1 /tmp/mima.log|passwd --stdin &
"#gp‘|bash
第三种方法:
[[email protected] ~]# echo stu{3..4}:$RANDOM|tee /tmp/useradd.log|xargs -n1|awk -F ":" ‘{print "useradd "$1";echo "$2"|passwd --stdin "$1""}‘|bash
第四种方法:
[[email protected] ~]# echo stu{01..10}|xargs -n1|awk ‘{print "useradd "$1" \&\& echo $RANDOM|md5sum|cut -c4-11 >>/tmp/mima.log \&\& echo tail -1 /tmp/mima.log
|passwd --stdin "$1""}‘|bash
第5种方法:
[[email protected] ~]# seq -f "oldboy%02g" 10|awk ‘{print "echo "$0" >>/tmp/mima.txt \&\& useradd "$0" \&\& op=$(date+%F|md5sum|cut -c1-8) \&\& echo $op|passwd --stdin "$0" \&\& echo $op >>/tmp/mima.txt"}‘|bash
第六种方法:
运用脚本
#!/bin/bash
#This is the creation of the post-90s Liu Zhonghe at 2017-12-27 19:30
for n in seq 3 4
do
useradd user$n
echo "user$n:user$necho user$n|md5sum|cut -c5-9
"|chpasswd
done
原文地址:http://blog.51cto.com/lzhnb/2084362