温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

批量创建用户及密码

发布时间:2020-07-05 14:52:09 来源:网络 阅读:731 作者:baishuchao 栏目:开发技术

批量创建用户并设置密码不为相同

#!/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



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI