zoukankan      html  css  js  c++  java
  • shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。

    [root@localhost wyb]# cat user10.sh 
    #!/bin/bash
    #批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
    >user.list
    for user in `seq -w 10`
    do
      
       useradd wangyb$user
       password=`echo $RANDOM|md5sum|cut -c 1-8`
       echo $password|passwd wangyb$user --stdin
       echo wangyb$user $password >> user.list
    done
    
    
    
    [root@localhost wyb]# bash user10.sh 
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb01.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb02.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb03.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb04.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb05.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb06.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb07.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb08.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb09.
    passwd: all authentication tokens updated successfully.
    Creating mailbox file: File exists
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.
    Changing password for user wangyb10.
    passwd: all authentication tokens updated successfully.
    [root@localhost wyb]# cat user.list 
    wangyb01 77950e07
    wangyb02 ace3cfb1
    wangyb03 2cd63081
    wangyb04 0f891e3c
    wangyb05 600bedd4
    wangyb06 73d3dfdc
    wangyb07 30740006
    wangyb08 54cf685f
    wangyb09 ee3f88af
    wangyb10 b54d2555
    [root@localhost wyb]# su wang01
    su: user wang01 does not exist
    [root@localhost wyb]# su wangyb01
    [wangyb01@localhost wyb]$ su wangyb10
    Password: 
    [wangyb10@localhost wyb]$ 
    
    [root@localhost wyb]# cat deluser10.sh 
    #!/bin/bash
    #批量删除10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。
    > user.list
    for user in `seq -w 10`
    do
      
       userdel wangyb$user
    done
    
    
    
    [root@localhost wyb]# bash deluser10.sh 
    [root@localhost wyb]# su wangyb01
    su: user wangyb01 does not exist
    [root@localhost wyb]# 
  • 相关阅读:
    智能聊天机器人——基于RASA搭建
    十分钟学会写shell脚本
    浅谈并发并行异步同步
    C/S系统实现两数求和(非阻塞+epoll+心跳包检测用户在线状况+滚动日志+配置文件.)
    编程之美第一篇 01分数规划
    欧拉函数
    奇妙的算法之LCS妙解
    N种方法妙讲LIS算法
    基于FeignClient提供简单的用户查询服务
    SpringCloud简介
  • 原文地址:https://www.cnblogs.com/wangyuebo/p/5847676.html
Copyright © 2011-2022 走看看