- 论坛徽章:
- 24
|
本帖最后由 chengchow 于 2014-10-27 10:37 编辑
- #!/bin/bash
- ##user_list=($(cat /tmp/userlist.txt))
- user_list=(aa bb cc dd)
- if [ ! -f "/etc/passwd.list" ];then
- touch /etc/passwd.list
- chmod 600 /etc/passwd.list
- chown root:root /etc/passwd.list
- fi
- for ((i=0;i<${#user_list[*]};i++));do
- grep "^${user_list[$i]}:" /etc/passwd
- if [ $(echo $?) = 0 ];then
- echo -e "The \"${user_list[$i]}\" is exist,do nothing!"
- continue
- fi
- grep "^${user_list[$i]}:" /etc/passwd.list
- if [ $(echo $?) = 0 ];then
- echo -e "The \"${user_list[$i]}\" is exist,Please check /etc/passwd.list"
- continue
- fi
- useradd ${user_list[$i]}
- rand_pass=$(cat /dev/urandom | head -1 | md5sum | cut -b -6)
- echo "${user_list[$i]}:${user_list[$i]}${rand_pass}" | /usr/sbin/chpasswd
- usermod -G wheel ${user_list[$i]}
- echo -e "${user_list[$i]}:${user_list[$i]}${rand_pass}" >> /etc/passwd.list
- done
- exit 0
复制代码 回复 8# Shell_HAT
一个测试的脚本,不是很完善,HAT你可真尽责任啊
|
|