用户的批量添加与删除——方法一

来源:互联网 发布:吉林大学的网络教育 编辑:程序博客网 时间:2024/05/16 10:29
需创建两个配置文件stu.txt , passwd.txt (用户名为自己姓名简拼,以简拼shik为例)
#groupadd -g 800 shik2014#vim stu.txtshik001:x:801:800::/home/shik001:/bin/bashshik002:x:802:800::/home/shik002:/bin/bashshik003:x:803:800::/home/shik003:/bin/bashshik004:x:804:800::/home/shik004:/bin/bash#vim passwd.txtshik001:1234shik002:1234shik003:1234shik004:1234#!/bin/bashread -p "input flag " flagcase $flag in   "add")      newusers < "stu.txt"      pwunconv      chpasswd < "passwd.txt"      pwconv      ;;     "del")     cut -d":" -f1 /etc/passwd | grep  shik   | xargs -n 1 userdel         //此处grep 后要跟自己名字简拼     ;;     *)     echo "error flag!"     ;;  esacexit 0;
0 0
原创粉丝点击