《linux批量创建用户的脚本公开课.docx》由会员分享,可在线阅读,更多相关《linux批量创建用户的脚本公开课.docx(1页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、批量创建用户的脚本脚本其实有很多,这里介绍一种比较简单。 脚本内容:#!/bin/bashfor num in S(seq 1 20)#对num这卜变量进行赋值 douser=userSnum#对user味值.user = user 11user2,user3,user4user20useradd Suser#创建用户use”2。echo ABCabcl23# passwd -stdin Suser#给力“12。赋予用户密码:ABCabcl23#done.运行脚本后可以看到成功创建用户:rootftp shell# sh l.sh Changing password for user pass
2、wd: all authentication Changing password for user passwd: all authentication Changing password for user passwd: all authentication Changing password for user passwd: all authenticationuserl. tokens user2. tokens user3. tokens user4. tokensupdated successfully.updated successfully.updated successfull
3、y.updated successfully.成功八J也可以查看/etc/passwd:userl:x:500:500:/home/userl:/bin/bash user2:x:501:501:/home/user2:/bin/bash user3:x:502:502:/home/user3:/bin/bash user4:x:503:503:/home/user4:/bin/bash users:x:504:504:/home/user5:/bin/bash user6:x:505:505:/home/user6:/bin/bash user7:x:566:506:/home/user7:
4、/bin/bash user8:x:507:507:/home/user8:/bin/bash user9:x:508:508:/home/user9:/bin/bash userl0:x:509:509:/home/userIQ:/bin/bash userll:x:510:510:/home/userll:/bin/bash userl2:x:511:511:/home/user12:/bin/bash userl3:x:512:512:/home/userl3:/bin/bash userl4:x:513:513:/home/userl4:/bin/bash userl5:x:514:514:/home/user15:/bin/bash userl6:x:515:515:/home/userl6:/bin/bash userl7:x:516:516:/home/user17:/bin/bash userl8:x:517:517:/home/user18:/bin/bash userl9:x:518:518:/home/userl9:/bin/bash Jser20:x:519:519:/home/user20:/bin/bash