首页 > 代码库 > shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
[root@localhost wyb]# cat user10.sh #!/bin/bash#批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。>user.listfor user in `seq -w 10`do useradd wangyb$user password=`echo $RANDOM|md5sum|cut -c 1-8` echo $password|passwd wangyb$user --stdin echo wangyb$user $password >> user.listdone[root@localhost wyb]# bash user10.sh Creating mailbox file: File existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 existsuseradd: 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 77950e07wangyb02 ace3cfb1wangyb03 2cd63081wangyb04 0f891e3cwangyb05 600bedd4wangyb06 73d3dfdcwangyb07 30740006wangyb08 54cf685fwangyb09 ee3f88afwangyb10 b54d2555[root@localhost wyb]# su wang01su: user wang01 does not exist[root@localhost wyb]# su wangyb01[wangyb01@localhost wyb]$ su wangyb10Password: [wangyb10@localhost wyb]$ [root@localhost wyb]# cat deluser10.sh #!/bin/bash#批量删除10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。> user.listfor user in `seq -w 10`do userdel wangyb$userdone[root@localhost wyb]# bash deluser10.sh [root@localhost wyb]# su wangyb01su: user wangyb01 does not exist[root@localhost wyb]#
shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。