1、创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuser

[root@wen-7 ~]# useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser[root@wen-7 ~]# getent passwd testuser testuser:x:1234:1::/testdir/testuser:/bin/csh

2、修改testuser uid:4321,主组:root,辅助组:nobody,loginname:test,home:/home/test 家数据迁移

[root@wen-7 ~]# usermod -l test -u 4321 -g root -G nobody -d /home/test -m  testuser[root@wen-7 ~]# getent passwd testtest:x:4321:0::/home/test:/bin/csh

3、批量创建帐号:user1...user10

uid:3000-3009,shell:/bin/csh,home:/testdir/username

passwd:usernamepass

注意家目录相关配置,使用户正常登录

[root@w6 ~]# mkdir /testdir[root@w6 ~]# cat  user.sh user1:x:3001:3001::/testdir/user1:/bin/cshuser2:x:3002:3002::/testdir/user2:/bin/cshuser3:x:3003:3003::/testdir/user3:/bin/cshuser4:x:3004:3004::/testdir/user4:/bin/cshuser5:x:3005:3005::/testdir/user5:/bin/cshuser6:x:3006:3006::/testdir/user6:/bin/cshuser7:x:3007:3007::/testdir/user7:/bin/cshuser8:x:3008:3008::/testdir/user8:/bin/cshuser9:x:3009:3009::/testdir/user9:/bin/cshuser10:x:3010:3010::/testdir/user10:/bin/csh[root@w6 ~]# newusers user.sh [root@w6 ~]# tail -10 /etc/passwduser1:x:3001:3001::/testdir/user1:/bin/cshuser2:x:3002:3002::/testdir/user2:/bin/cshuser3:x:3003:3003::/testdir/user3:/bin/cshuser4:x:3004:3004::/testdir/user4:/bin/cshuser5:x:3005:3005::/testdir/user5:/bin/cshuser6:x:3006:3006::/testdir/user6:/bin/cshuser7:x:3007:3007::/testdir/user7:/bin/cshuser8:x:3008:3008::/testdir/user8:/bin/cshuser9:x:3009:3009::/testdir/user9:/bin/cshuser10:x:3010:3010::/testdir/user10:/bin/csh         [root@w6 ~]# cat passwd.sh |chpasswd [root@w6 ~]# cat passwd.sh user1:user1passuser2:user2passuser3:user3passuser4:user4passuser5:user5passuser6:user6passuser7:user7passuser8:user8passuser9:user9passuser10:user10pass[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user1[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user2[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user3[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user4[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user5[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user6[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user7[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user8[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user9[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user10[root@w6 ~]# ll -a /testdir/user1total 32drwx------.  4 user1 user1 4096 Jul 30 16:58 .drwxr-xr-x. 12 root  root  4096 Jul 30 16:53 ..-rw-r--r--.  1 root  root    18 Jul 30 16:58 .bash_logout-rw-r--r--.  1 root  root   176 Jul 30 16:58 .bash_profile-rw-r--r--.  1 root  root   124 Jul 30 16:58 .bashrcdrwxr-xr-x.  2 root  root  4096 Jul 30 16:58 .gnome2-rw-------.  1 user1 user1   53 Jul 30 16:56 .historydrwxr-xr-x.  4 root  root  4096 Jul 30 16:58 .mozilla[root@w6 ~]# ll -a /testdir/user2