练习
1、创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuser
[root@6 ~]# getent group ftp ##存在附加组root,ftp ftp:x:50: [root@6 ~]# getent group root root:x:0: [root@6 ~]# useradd -u 1234 -G root,ftp -s /bin/csh -d /testdir/testuser testuser [root@6 ~]# id testuser uid=1234(testuser) gid=1234(testuser) 组=1234(testuser),0(root),50(ftp) [root@6 ~]# finger testuser Login: testuser Name: Directory: /testdir/testuser Shell: /bin/csh Never logged in. No mail. No Plan.
2、修改testuser uid:4321,主组:root,辅助组:nobody,loginname:test,home:/home/test 家数据迁移
[root@6 ~]# usermod -u 4321 -g root -G nobody -l test -md /home/test testuser [root@6 ~]# id test uid=4321(test) gid=0(root) 组=0(root),99(nobody) [root@6 ~]# fingegr test -bash: fingegr: command not found [root@6 ~]# finger test Login: test Name: Directory: /home/test Shell: /bin/csh Never logged in. No mail. No Plan. [root@6 ~]# ls -a /home/test ##以迁移用户家目录至/home/test 文件夹 . .. .bash_logout .bash_profile .bashrc .gnome2 .mozilla
3、批量创建帐号:user1...user10
uid:3000-3009,shell:/bin/csh,home:/testdir/username
passwd:usernamepass
注意家目录相关配置,使用户正常登录
[root@6 ~]# cat a user1:x:3000:::/testdir/user1:/bin/csh user2:x:3001:::/testdir/user2:/bin/csh user3:x:3002:::/testdir/user3:/bin/csh user4:x:3003:::/testdir/user4:/bin/csh user5:x:3004:::/testdir/user5:/bin/csh user6:x:3005:::/testdir/user6:/bin/csh user7:x:3006:::/testdir/user7:/bin/csh user8:x:3007:::/testdir/user8:/bin/csh user9:x:3008:::/testdir/user9:/bin/csh user10:x:3009:::/testdir/user10:/bin/csh [root@6 ~]# newusers a [root@6 ~]# tail -10 /etc/passwd user1:x:3000:3000::/testdir/user1:/bin/csh user2:x:3001:3001::/testdir/user2:/bin/csh user3:x:3002:3002::/testdir/user3:/bin/csh user4:x:3003:3003::/testdir/user4:/bin/csh user5:x:3004:3004::/testdir/user5:/bin/csh user6:x:3005:3005::/testdir/user6:/bin/csh user7:x:3006:3006::/testdir/user7:/bin/csh user8:x:3007:3007::/testdir/user8:/bin/csh user9:x:3008:3008::/testdir/user9:/bin/csh user10:x:3009:3009::/testdir/user10:/bin/csh [root@6 ~]# cat b user1:user1pass user2:user2pass user3:user3pass user4:user4pass user5:user5pass user6:user6pass user7:user7pass user8:user8pass user9:user9pass user10:user10pass [root@6 ~]# cat b |chpasswd [root@6 ~]# tail -10 /etc/shadow user1:$6$Zn875kqO7lyhspB$VA0mo0ktMhD1ZksanP3Rd796oDBzHwM39aeskZCVZaz.CyRhvr3lu5qeT2FEKAZ7Zd1qCu3CNMv/Pl9EERIk./:17014:0:99999:7::: user2:$6$S9xAk/T38gt/$04CwoQvLfCm8g/U1AlLc3Zca1AaaBgpbSNj.8lMFpaxlFKPq/GQ5gf/.YWocQZAHL9jZQ6yHVNM.MRntP5aB/.:17014:0:99999:7::: user3:$6$TTS6uiR2hjTgiEr/$iqYe0tkW5ov9pOKHhNsfLzmDPzm4omMrrKds5Iyhsj6Mab/Eo0plDOCc/CC6O50QMHOctnE2dankZ5ioV5rYq1:17014:0:99999:7::: user4:$6$SSX9E/Dgp$izBCV2fWNQnPHCSsKC4eJI0we5qA2VyuzcWQ3Wkx5fMSrajPMaA28v.Id4oBT1YZygRvDgt9JiC0rE6yqiRy20:17014:0:99999:7::: user5:$6$Bq14upSD2kPp$.JhKRi4Kv5V.Eu3nh4E6V2LWMbZNs6ZKJ7wZcKuKel/SH0MI1xEtzSOY.hp7mjIvau3JBR4SMweL35qh9h9l70:17014:0:99999:7::: user6:$6$5PZDI/Runxn$gEDmD2Qh2bZhJan.6HPLqko9Hg3eVh.ACWaOWf858KjUksy1f1d.UfeAh/y0MWSy27AOtGw2wFpEMR0p9FigQ0:17014:0:99999:7::: user7:$6$VA5sVIxyhuWx4$5ii05kk4qRhLnlEe5oG4fUhmLEimzafXavMNdbF6bKC9Eflhsqt5PX8oePc6Y0Fsi9ggQlC4p74W1rGDNyA2j1:17014:0:99999:7::: user8:$6$zWvBzIilwOWZZ$XTEpTLMZHliWCKYdncg5DjMDuc9jzbHcy/BSMBV6rg6XrljD9MPnmv49A/XfcRCtSiEBdf/t8N2pUiTFAOI3Z/:17014:0:99999:7::: user9:$6$cEaoH/tT$yKzL.Ar4nPaTMkpdK9TYySR1BNEolDt5wZCVOhceuDMCyRbtTwd/ojDHdXj8RdZu8MPgiKdSZKfUxtTOv68WM0:17014:0:99999:7::: user10:$6$M5/y2rBp$io6ZM4b1RS/GtDeb6wtcrlsq9UaEjQlo.swJyQuheciGG3eCXC1pvx1mpo0.p8cM5gFVOvarlwSU0AXnVxwie/:17014:0:99999:7::: [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user1 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user2 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user3 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user4 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user5 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user6 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user7 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user8 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user9 [root@6 ~]# cp -r /etc/skel/.[^.]* /testdir/user10