批量新建系统账号Shell脚本
#!/bin/bash #this shell is useradd more #1.check account1.txt and get username #2.create useradd #3.update passwd #2015-7-16 export PATH=/bin:/sbin:/usr/bin:/usr/sbin #check account1.txt if [ ! -f account1.txt ];then echo "sorry,account1.txt no find,please create account1.txt" exit 1 fi usernames=$(cat account1.txt) for username in $usernames do useradd $username echo $username | passwd --stdin $username chage -d 0 $username done
新建账号文本 account1.txt
std01 std02 std03 std04 std05
这样执行脚本后系统会添加std01、std02、std03、std04、std05五个账号