您当前的位置: 首页 >  linux

江湖有缘

暂无认证

  • 0浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Linux下shell脚本实战之批量新建用户

江湖有缘 发布时间:2021-04-30 13:38:23 ,浏览量:0

Linux下shell脚本实战之批量新建用户
  • 一、脚本要求
  • 二、脚本内容
  • 三、运行脚本

一、脚本要求 二、脚本内容 三、运行脚本

一、脚本要求

1.使用提供的user.txt用户列表 2.批量新建user.txt中用户

二、脚本内容 1.查看用户列表文件

[root@control scripts]# cat user.txt 
redhat
huawei
user100
user200

2.脚本内容

#!/bin/bash
##########################################################
#File Name:user.sh
#Version:V1.0
#Aurhor:  
#Emali:
#Created Time:2021-04-30 13:29:13
#Description:
#creat user for userlist
##########################################################


for i in $(cat /scripts/user.txt)
do 
       USERS=$i
       useradd $USERS
                 if [ $? != 0 ];then
                      break
                 fi
      echo "$USERS" | passwd --stdin $USERS
done

关注
打赏
1665849170
查看更多评论
立即登录/注册

微信扫码登录

0.0372s