您的位置:首页 > 其它

DELL R610安装 ubuntu11.04无法启动问题解决方案

2011-07-06 10:36 357 查看
#!/bin/bash
#实现批量添加20个用户,用户名为user1-50,密码为user后面跟5个随机字符
for i in `seq 1 50`
do
pw=`echo $[$RANDOM]|md5sum|cut -c 1-5`
useradd user$i
echo "user$i $pw" >> /root/pw.txt
echo "user$pw" |passwd --stdin user$i
done
注意:生成随机密码后直接给用户设定了,但是我并不知道随机密码是什么啊。所以加了一个随机密码定向到一个文件中,方便管理。格式为:用户名 后面跟随机字符;举例如下:
[root@localhost ~]# cat /root/pw.txt
user1 3e9db
user2 febb6
user3 43c55
.........................

其他生成随机字符的方法:
1:生成的随机字符为字母加数字组合
[root@localhost ~]# cat /dev/urandom | head -1|md5sum |head -c 5
cf93d
[root@localhost ~]# cat /dev/urandom | head -1|md5sum |head -c 5
75217
2:生成的随机字符包含特殊字母
[root@localhost ~]# cat /dev/urandom | strings -n 5 | head -n 1
O4%"G
[root@localhost ~]# cat /dev/urandom | strings -n 5 | head -n 1
mMSxu

本文出自 “boyhack” 博客,请务必保留此出处http://461205160.blog.51cto.com/274918/1743875
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐