[root@localhost wyb]# cat user10.sh
#!/bin/bash
#批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
>user.list
for user in `seq -w `
do useradd wangyb$user
password=`echo $RANDOM|md5sum|cut -c -`
echo $password|passwd wangyb$user --stdin
echo wangyb$user $password >> user.list
done [root@localhost wyb]# bash user10.sh
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb01.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb02.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb03.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb04.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb05.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb06.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb07.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb08.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb09.
passwd: all authentication tokens updated successfully.
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Changing password for user wangyb10.
passwd: all authentication tokens updated successfully.
[root@localhost wyb]# cat user.list
wangyb01 77950e07
wangyb02 ace3cfb1
wangyb03 2cd63081
wangyb04 0f891e3c
wangyb05 600bedd4
wangyb06 73d3dfdc
wangyb07
wangyb08 54cf685f
wangyb09 ee3f88af
wangyb10 b54d2555
[root@localhost wyb]# su wang01
su: user wang01 does not exist
[root@localhost wyb]# su wangyb01
[wangyb01@localhost wyb]$ su wangyb10
Password:
[wangyb10@localhost wyb]$ [root@localhost wyb]# cat deluser10.sh
#!/bin/bash
#批量删除10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
> user.list
for user in `seq -w `
do userdel wangyb$user
done [root@localhost wyb]# bash deluser10.sh
[root@localhost wyb]# su wangyb01
su: user wangyb01 does not exist
[root@localhost wyb]#

shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。的更多相关文章

  1. 批量创建10个系统帐号tianda01-tianda10并设置密码

    #.添加用户 useradd tianda01 #.非交互式给密码 echo "pass"|passwd --stdin tianda #.- 加0思路 ()..} () #随机密 ...

  2. Shell 脚本批量创建数据库表

    使用 Shell 脚本批量创建数据表 系统:Centos6.5 64位 MySQL版本:5.1.73 比如下面这个脚本: #!/bin/bash #批量新建数据表 for y in {0..199}; ...

  3. Linux shell脚本 批量创建多个用户

    Linux shell脚本 批量创建多个用户 #!/bin/bash groupadd charlesgroup for username in charles1 charles2 charles3 ...

  4. 案例九:shell脚本自动创建多个新用户,并设置密码

    此脚本是用来批量创建用户并设置用户密码,在企业用非常实用. 脚本一 #!/bin/bash for name in $( seq 1 100 ) do useradd "user$name& ...

  5. shell脚本批量创建用户

    #!/bin/bash DATE=$(date +%F_%T) USER_FILE=user.txt echo_color() { == "green" ];then echo - ...

  6. 基于Andoird 4.2.2的Account Manager源代码分析学习:创建选定类型的系统帐号

    AccountManager.addAccount() public AccountManagerFuture<Bundle> addAccount(final String accoun ...

  7. shell脚本,在指定目录下通过随机小写10个字母加固定字符串oldboy批量创建10个html文件。

    [root@localhost wyb]# cat test10.sh #!/bin/bash #使用for循环在/test10目录下通过随机小写10个字母加固定字符串oldboy批量创建10个htm ...

  8. linux系统配置文件或shell脚本批量注释

    1. 配置文件批量注释 1.1 批量注释 ① 进入命令行模式,按ctrl + v进入 visual block模式,键盘上下箭头选中多行,把需要注释的行标记起来 ② 按大写字母I,再输入注释符:# ③ ...

  9. 批量创建10个用户stu01-stu10

    1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...

随机推荐

  1. POJ3414(BFS+[手写队列])

    贴一发自己写的手写队列-.. #include <stdio.h> #include <iostream> #include <string.h> #include ...

  2. Response.Redirect 产生的“正在中止线程”错误

    Response.Redirect 产生的“正在中止线程”错误 今天在开发调试过程中,出现在一个 "正在中止线程"异常信息. 调用Response.Redirect()方法产生的, ...

  3. BZOJ1415(期望dp)

    解法: 首先bfs预处理go数组:可可在j点时聪聪在点i是怎样贪心走的,这是为了之后O(1)获取转移线路. 然后dfs记忆化一下f[i][j],代表从i到j的期望,对于每层:将所有情况的期望值相加.边 ...

  4. Linux之文本处理命令

    Sort 将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次按ASCII码值进行比较,最后将他们按升序输出. -u     在输出行中去除重复行 -r      改为降序(默认升序) ...

  5. python入门之正则表达式

    正则 通过re模块实现 eg:>>>import re        >>>re.findall('abc',str_name) 在strname里面完全匹配字符串 ...

  6. 如何在VirtualBox虚拟机中安装XP系统? 转

    关闭VM (windows 7 )的方法, 使用 退出 保持状态 开启VM (windows 7 )的方法, 选择启动 ######Iissue 1 网络连接不上,可以重新初始化 网络连接. #### ...

  7. LM358与TL431验证

  8. Spring-打印机案例

    1.导包 <!--beans--><dependency> <groupId>org.springframework</groupId> <art ...

  9. js AES对称加密 16进制和base64格式

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  10. Spring AOP初步总结(一)

    学习AOP有段时间了,一直没空总结一下,导致有些知识点都遗忘了,之后会把以前学过的Spring核心相关的知识点总结一轮... 先大体介绍下Spring AOP的特点(均摘自"Spring i ...