练习:编写一个脚本,可以自动建立用户,及匹配密码
来源:互联网 发布:淘宝买手店 编辑:程序博客网 时间:2024/05/29 08:18
有两个文件userfile及passwdfile,分别存有用户名和密码,编写一个脚本,可以自动识别userfile里的用户名,然后建立此用户名,并且匹配passwdfile里的密码
文件内容如下
[root@localhost ~]# cat userfile user1user2user3[root@localhost ~]# cat passwdfile 123123123
[root@localhost ~]# vim lianxi.sh下边是脚本内容#!/bin/bashMAX_LINE=`wc -l $1 | awk -F " " '{printf $1}'`for NUM in `seq 1 $MAX_LINE`do USERNAME=`sed -n ${NUM}p $1` useradd $USERNAME > /dev/null echo $(sed -n ${NUM}p passwdfile) | passwd $USERNAME --stdindone
测试结果:[root@localhost ~]# sh lianxi.sh userfileChanging password for user user1.passwd: all authentication tokens updated successfully.Changing password for user user2.passwd: all authentication tokens updated successfully.Changing password for user user3.passwd: all authentication tokens updated successfully.[root@localhost ~]# id user1uid=1001(user1) gid=1001(user1) groups=1001(user1)[root@localhost ~]# id user2uid=1002(user2) gid=1002(user2) groups=1002(user2)[root@localhost ~]# id user3uid=1003(user3) gid=1003(user3) groups=1003(user3)[root@localhost ~]#
0 0
- 练习:编写一个脚本,可以自动建立用户,及匹配密码
- 用户自动建立脚本
- 自动建立用户脚本
- 脚本建立用户并设置密码
- 编写脚本 直接可以通过authconfig 认证ldap用户,并且开机自动
- shell 脚本增加smb用户及密码
- Linux自动切换用户脚本,自动输入用户名密码
- 【shell脚本练习】批量添加用户和设置密码
- DataGridViewComboBoxColumn 可以让用户输入并自动匹配选项
- 批量建立用户+SSH自动登录+DDNS服务配置脚本
- 建立用户脚本
- 编写一个可以自动执行的.jar文件
- 练习: 用脚本实现自动建立swap分区,并自动激活
- 通过VBS编写自动输入账号和密码、自动登录程序的脚本
- ORACLE创建表空间、删除用户与建立用户及权限及导入导出脚本
- 用户自动创建脚本
- shell脚本编写-基础练习
- DataGridViewComboBoxColumn 可以让用户输入并自动匹配选项的问题
- SolrCloud安装
- j_spring_security_logout 404
- SDNU 1089.拓扑排序 ...
- java并发(五)Callable接口
- spring+redis整合
- 练习:编写一个脚本,可以自动建立用户,及匹配密码
- PHP设计模式系列(十七):桥接模式
- Markdown
- <模型汇总_4>神经翻译模型(NMT)新宠_Adversarial Neural Machine Translation_Adversarial-NMT
- cocos creator配置原生平台调试遇到的一些问题
- android中 异步消息处理机制及Handler
- 《深入理解计算机系统》第二章部分习题
- python 数组的del ,remove,pop区别
- java面试题——三大框架的核心:Java反射机制和Spring控制反转和依赖注入