Chinaunix

标题: Batch create users [打印本页]

作者: ruconse    时间: 2008-09-05 09:41
标题: Batch create users

                   Batch create users
The newusers command can create a lot of users.So we create a shell script to use newusers to create users batchly.
Now is the scripts:
######################################################################
#!/bin/bash
password=101 # specify the passwd
ugid=500 # specify the gid and uid
for user in n30{101..120} # specify the username is n30101 to n30120
do
echo "$user:$password:$ugid:$ugid::/home/$user:/bin/bash" | newusers
# if you want the new users all belong to the specify group,you can use
# echo "$user:$password:$ugid:users::/home/$user:/bin/bash" | newusers
# now all the new users are beong to the users group.
ugid=$(($ugid+1))
password=$(($password+1))
cp /etc/skel/.* /home/$user
done
#######################################################################
Now if you wan to delete all the new users,you can use this script
########################################################################
#!/bin/bash
for user in n30{101..120}
do
userdel -r $user
done
########################################################################



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/47864/showart_1165042.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2