shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
[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位字符串。的更多相关文章
- 批量创建10个系统帐号tianda01-tianda10并设置密码
#.添加用户 useradd tianda01 #.非交互式给密码 echo "pass"|passwd --stdin tianda #.- 加0思路 ()..} () #随机密 ...
- Shell 脚本批量创建数据库表
使用 Shell 脚本批量创建数据表 系统:Centos6.5 64位 MySQL版本:5.1.73 比如下面这个脚本: #!/bin/bash #批量新建数据表 for y in {0..199}; ...
- Linux shell脚本 批量创建多个用户
Linux shell脚本 批量创建多个用户 #!/bin/bash groupadd charlesgroup for username in charles1 charles2 charles3 ...
- 案例九:shell脚本自动创建多个新用户,并设置密码
此脚本是用来批量创建用户并设置用户密码,在企业用非常实用. 脚本一 #!/bin/bash for name in $( seq 1 100 ) do useradd "user$name& ...
- shell脚本批量创建用户
#!/bin/bash DATE=$(date +%F_%T) USER_FILE=user.txt echo_color() { == "green" ];then echo - ...
- 基于Andoird 4.2.2的Account Manager源代码分析学习:创建选定类型的系统帐号
AccountManager.addAccount() public AccountManagerFuture<Bundle> addAccount(final String accoun ...
- shell脚本,在指定目录下通过随机小写10个字母加固定字符串oldboy批量创建10个html文件。
[root@localhost wyb]# cat test10.sh #!/bin/bash #使用for循环在/test10目录下通过随机小写10个字母加固定字符串oldboy批量创建10个htm ...
- linux系统配置文件或shell脚本批量注释
1. 配置文件批量注释 1.1 批量注释 ① 进入命令行模式,按ctrl + v进入 visual block模式,键盘上下箭头选中多行,把需要注释的行标记起来 ② 按大写字母I,再输入注释符:# ③ ...
- 批量创建10个用户stu01-stu10
1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...
随机推荐
- perl 安装LOG4perl 模块
环境信息 ubuntu 12.04 64位 桌面版 Log-Log4perl 的介绍网址:http://search.cpan.org/~mschilli/Log-Log4perl-1.49/lib/ ...
- 转 Vlan
1.支持VLAN的交换机一定是三层交换机吗?2.Trunk配置了就可以VLAN间通信吗?3.Trunk具体怎么工作的?4.VLAN间的通信到底是怎么执行的?如果说给若干个纯二层环境加上若干个路由器,我 ...
- scrapy的中间件Downloader Middleware实现User-Agent随机切换
scrapy的中间件Download Middleware实现User-Agent随机切换 总架构理解Middleware 通过scrapy官网最新的架构图来理解: 从图中我们可以看出,在spid ...
- 2017浙江工业大学-校赛决赛 小M和天平
Description 小M想知道某件物品的重量,但是摆在他面前的只有一个天平(没有游标)和一堆石子,石子可以放左边也可以放右边.他现在知道每个石子的重量.问能不能根据上述条件,能不能测出所问的重量. ...
- C51 笔记
一 关于宏常量的长度:C51中定义一个常数宏(默认是16位的),如果用宏表示一个32位的宏而不加'L'标志的话就会出错.如 #define BLOCK_A_BASEADDR 18*64*1024 / ...
- 17999 Light-bot 模拟 + kmp求循环节
http://acm.scau.edu.cn:8000/uoj/mainMenu.html 17999 Light-bot 时间限制:1000MS 内存限制:65535K 提交次数:0 通过次数:0 ...
- PHP采集利器 Snoopy 试用心得
Snoopy是什么? Snoopy是一个php类,用来模仿web浏览器的功能,它能完成获取网页内容和发送表单的任务. Snoopy的一些特点: * 方便抓取网页的内容 * 方便抓取网页的文本内容 (去 ...
- 小程序 显示Toobar
要实现的效果 在 下面app.json 中加下列代码 "tabBar": { "color": "#7A7E83", "se ...
- jvm内存溢出的三种情况以及解决办法
1 前言相信有一定java开发经验的人或多或少都会遇到OutOfMemoryError的问题,这个问题曾困扰了我很长时间,随着解决各类问题经验的积累以及对问题根源的探索,终于有了一个比较深 ...
- Springboot2.X集成Quartz集群
为什么要使用Quzrtz集群 在项目进行集群部署时,如果业务在执行中存在互斥关系,没有对定时任务进行统一管理,就会引起业务的多次执行,不能满足业务要求.这时就需要对任务进行管理,要保证一笔业务在所有的 ...