用脚本批量创建用户user_00 ... user_20, 并且给这些用户设置一个随机密码,并记录到一个日志文件中。
答案:
{{{密码回复可见}}}
答案:
{{{密码回复可见}}}
0
for i in `seq -f "user_%02g" 1 20`
do
useradd $i
pw=`echo $RANDOM`
echo $pw|passwd --stdin $i
echo $i:$pw>>yonghu.log
done
do
useradd $i
pw=`echo $RANDOM`
echo $pw|passwd --stdin $i
echo $i:$pw>>yonghu.log
done
0
- #!/bin/bash
- ##written by wangyl
- ##2016-04-06
- for i in `seq 1 20`;
- do
- useradd user$i
- passwd=`mkpasswd -s 0`
- echo -e "$passwd\n$passwd" | passwd user$i
- done
0
#!/bin/bash/
#
#
for u in `seq 1 20`
do
useradd "$u"user
p=`mkpasswd`
echo "$u"user:$p >> user.log
done
#
#
for u in `seq 1 20`
do
useradd "$u"user
p=`mkpasswd`
echo "$u"user:$p >> user.log
done
0
[root@NewHost shell]# vim adduser.sh
#!/bin/bash
for i in `seq -w 00 20`
do
password=`echo $RANDOM`
useradd user_$i
echo $password|passwd --stdin user_$i
echo "username:user_$i,password:$password" >> /root/adduser.log
done
#!/bin/bash
for i in `seq -w 00 20`
do
password=`echo $RANDOM`
useradd user_$i
echo $password|passwd --stdin user_$i
echo "username:user_$i,password:$password" >> /root/adduser.log
done
0
- [root@localhost sbin]# cat user.sh
- #!/bin/bash
- ##author:lin
- for i in `seq -w 0 20`
- do
- useradd user_$i
- a=$RANDOM
- echo "user_$i:$a" >> /tmp/1.txt
- echo "$a" | passwd --stdin user_$i
- done
0
Coohx - 小运维
#!/bin/bash
# 批量删除用户 user_00 ---user_20
for count in `seq -w 0 20`
do
userdel -r user_$count &>/dev/null
done
{:4_95:}
# 批量删除用户 user_00 ---user_20
for count in `seq -w 0 20`
do
userdel -r user_$count &>/dev/null
done
{:4_95:}
0
#/bin/bash
pass=`mkpasswd`
for i in `seq 00 20`
do useradd user_$i
echo $pass|passwd --stdin user_$i 1>> /tmp/user.log
done
pass=`mkpasswd`
for i in `seq 00 20`
do useradd user_$i
echo $pass|passwd --stdin user_$i 1>> /tmp/user.log
done
0
#! /bin/bash
for i in `seq 00 20`
do
useradd user_$i
pw=`mkpasswd`
echo $pw |passwd --stdin user_$i > /dev/null
echo "user_$i:$pw" >> /tmp/useradd.log
done
for i in `seq 00 20`
do
useradd user_$i
pw=`mkpasswd`
echo $pw |passwd --stdin user_$i > /dev/null
echo "user_$i:$pw" >> /tmp/useradd.log
done
0
#! /bin/bash
for i in `seq -w 00 20`
do
useradd user_$i
passwd=`mkpasswd -l 10 -s 0`
echo $passwd | passwd --stdin user_$i
echo "user_$i $passwd" >> /tmp/1.txt
done
编辑回复