Ubuntu 批量添加用户/批量删除用户

批量添加用户

1 . 准备文件 ws1_2015_add.sh

        #!/bin/bash
        for i in h230300033 i330003002 i330003004
        do
        mkdir /opt/lampp/htdocs/ws2015/$i
        chmod -R 755 /opt/lampp/htdocs/ws2015/$i
        useradd -d /opt/lampp/htdocs/ws2015/$i -g ftpusers -s /sbin/nologin $i
        chown $i /opt/lampp/htdocs/ws2015/$i
        chgrp ftpusers /opt/lampp/htdocs/ws2015/$i
        done

2 . 运行脚本批量添加用户

./ws1_2015_add.sh

3 . 准备密码文本 passwd.txt

        h230300033:h230300033
        i330003002:i330003002
        i330003004:i330003004

4 . 执行命令批量更改 密码

chpasswd < passwd.txt

批量删除用户

  1. 准备脚本 del_users.sh
#!/bin/bash
for i in h230300033 i330003002 i330003004 
do
userdel -r $i
done
  1. 运行脚本
./del_users.sh

你可能感兴趣的:(Ubuntu 批量添加用户/批量删除用户)