Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9069
  • 博文数量: 3
  • 博客积分: 140
  • 博客等级: 入伍新兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-05 15:35
文章分类
文章存档

2008年(3)

我的朋友
最近访客

分类: LINUX

2008-09-05 09:41:49

                   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
########################################################################
阅读(599) | 评论(0) | 转发(0) |
0

上一篇:LFS播放音乐

下一篇:没有了

给主人留下些什么吧!~~