批量创建用户及密码

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

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

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



推荐阅读:
  1. Office365如何批量创建用户
  2. shell 脚本应用《七》批量创建用户

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

用户 创建 批量

上一篇:应对新兴威胁——国都兴业恶意代码综合监控系统发布

下一篇:Exchange2010清理不存在,已下线的exchange服务器,并重建系统仲裁邮箱

相关阅读

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

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