批量创建用户并设置密码不为相同
#!/bin/bash for n in `seq -w 10` do useradd xcn$n&&\ echo "root$n"|passwd --stdin xcn$n done 执行结果: [root@XCN for]# sh test7.sh Changing password for user xcn01. passwd: all authentication tokens updated successfully. Changing password for user xcn02. passwd: all authentication tokens updated successfully. Changing password for user xcn03. passwd: all authentication tokens updated successfully. Changing password for user xcn04. passwd: all authentication tokens updated successfully. Changing password for user xcn05. passwd: all authentication tokens updated successfully. Changing password for user xcn06. passwd: all authentication tokens updated successfully. Changing password for user xcn07. passwd: all authentication tokens updated successfully. Changing password for user xcn08. passwd: all authentication tokens updated successfully. Changing password for user xcn09. passwd: all authentication tokens updated successfully. Changing password for user xcn10. passwd: all authentication tokens updated successfully.
批量创建用户并设置密码为随机
方法1:
#!/bin/bash for n in `seq -w 10` do pass=`echo "$RANDOM"|md5sum|cut -c 1-8` useradd xcn$n&&\ echo "$pass" |passwd --stdin xcn$n echo -e "xcn$n\t $pass" >>/data/pass.log done
批量删除用户
#!/bin/bash for n in `seq 10` do userdel -r xcn$n &&\ done
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。