Chinaunix首页 | 论坛 | 博客
  • 博客访问: 181385
  • 博文数量: 77
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 45
  • 用 户 组: 普通用户
  • 注册时间: 2016-08-25 10:50
文章分类

全部博文(77)

文章存档

2018年(1)

2017年(3)

2016年(4)

2015年(4)

2014年(16)

2013年(7)

2012年(20)

2011年(22)

分类: LINUX

2011-12-23 10:53:34

图片介绍:松金洋子,著名美女模特。

正文:

当年有台ftp服务器挂了,然后要用另台拿来顶用,但是有上百个用户,一个一个创建明显不太靠谱,当初是峰哥搞的,我也不知道是咋弄的,后来才知道。开始我还以为是修改/etc/passwd文件呢。
[root@testcms sh]# cat li.sh 
!/bin/bash
aa=(q w e r t)
pp=(a s d f g)
for i in ${aa[*]}
  do
        useradd $i
        echo ${pp[*]} | passwd --stdin $i
done

[root@testcms sh]# 
[root@testcms sh]# sh li.sh 
li.sh: line 1: !/bin/bash: No such file or directory
Changing password for user q.
passwd: all authentication tokens updated successfully.
Changing password for user w.
passwd: all authentication tokens updated successfully.
Changing password for user e.
passwd: all authentication tokens updated successfully.
Changing password for user r.
passwd: all authentication tokens updated successfully.
Changing password for user t.
passwd: all authentication tokens updated successfully
[root@testcms sh]#
[root@testcms sh]# cat /etc/passwd
q:x:514:514::/home/q:/bin/bash
w:x:515:515::/home/w:/bin/bash
e:x:516:516::/home/e:/bin/bash
r:x:517:517::/home/r:/bin/bash
t:x:518:518::/home/t:/bin/bash
[root@testcms sh]# su - q
[q@testcms ~]$
####################################################################################
!/bin/bash
aa=(q w e r t)
pp=(a s d f g)
for i in ${aa[*]}
  do
        useradd $i
        echo ${pp[*]} | passwd --stdin $i
done
####################################################################################
这个主要就是用到三个知识点:
1.数组
2.for 
3.passwd --stdin 

本文转载自:http://blog.chinaunix.net/space.php?uid=25892360&do=blog&id=3047411

阅读(878) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~