加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

批量创建linux用户

发布时间:2020-12-13 22:44:02 所属栏目:Linux 来源:网络整理
导读:AWK [[email?protected] ~]# seq -w 100|awk ‘{print "useradd user"$1";echo $RANDOM|md5sum|cut -c 1-10|tee /root/pass.txt"$1"|passwd --stdin user"$1}‘|bash Changing password for user user001. passwd: all authentication tokens updated succes
AWK

[[email?protected] ~]# seq -w 100|awk ‘{print "useradd user"$1";echo $RANDOM|md5sum|cut -c 1-10|tee /root/pass.txt"$1"|passwd --stdin user"$1}‘|bash
Changing password for user user001.
passwd: all authentication tokens updated successfully.
Changing password for user user002.
passwd: all authentication tokens updated successfully.
Changing password for user user003.
passwd: all authentication tokens updated successfully.
......
passwd: all authentication tokens updated successfully.
Changing password for user user099.
passwd: all authentication tokens updated successfully.
Changing password for user user100.
passwd: all authentication tokens updated successfully.

SED

[[email?protected] ~]# seq -w 100|sed -nr ‘s#(.*)#useradd seduser1#gp‘ |bash
[[email?protected] ~]# cat /etc/passwd|grep seduser|wc -l
100

Shell

[[email?protected] ~]# cat shell.sh
for i in $(seq -w 100);do
useradd shelluser$i
done
[[email?protected] ~]# sh shell.sh
[[email?protected] ~]# cat /etc/passwd|grep shellshelluser001:x:1192:1193::/home/shelluser001:/bin/bashshelluser002:x:1193:1194::/home/shelluser002:/bin/bash......shelluser099:x:1290:1291::/home/shelluser099:/bin/bashshelluser100:x:1291:1292::/home/shelluser100:/bin/bash

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读