ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 用shell自动创建用户

用shell自动创建用户

原创 Linux操作系统 作者:邪丶坏人 时间:2016-10-12 11:03:44 0 删除 编辑
把需要创建的用户名放在一个文件里,然后自动创建这些用户
效果图




代码如下:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. read -p "please enter the user's password: " passwd
  3. for user in `cat /xie/q.txt`
  4. do
  5. id $user &> /dev/null
  6. if [ $? -eq 0 ]
  7. then
  8. echo "user $user is exists"
  9. else
  10. useradd $user
  11. echo "$passwd" | passwd --stdin $user &> /dev/null
  12. if [ $? -eq 0 ]
  13. then
  14. echo "user $user create successfully"
  15. else
  16. echo "user $user create failed"
  17. fi
  18. fi
  19. done

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31098809/viewspace-2126162/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
多年的DBA从业经验,有扎实的linux和Oracle运维和故障处理的能力; 对oracle rac,adg,ogg,rman备份恢复,异机恢复,分区表,数据迁移,sql优化,版本升级,数据库架构设计,故障处理都较为熟练

注册时间:2016-04-01

  • 博文量
    53
  • 访问量
    124327