1 、創建 用戶gentoo ,附加組為bin 和root ,默認shell為/bin/csh ,注釋信息為"Gentoo Distribution"
1
|
useradd -G bin,root -s /bin/csh -c "Gentoo Distribution" gentoo |
2 、創建 下面的用戶、組和組成員關系,名字為 為admins的組
用戶natasha ,使用admins 作為附屬組
用戶harry ,也使用admins 作為附屬組
用戶sarah ,不可交互登錄系統, 且 不是admins的成員,natasha ,harry ,sarah 密碼 都是centos
1
2
3
4
5
6
|
useradd -G admins natasha useradd -G admins harry useradd -r -s /sbin/nologin sarah echo "centos" | passwd --stdin=natasha echo "centos" | passwd --stdin=harry echo "centos" | passwd --stdin=sarah |
3、創建testuser uid 1234,主組:bin,輔助組:root,ftp,shell:/bin/csh home:/testdir/testuser
1
|
useradd -u 1234 -g bin -G root, ftp -s /bin/csh -d /testdir/testuser testuser |
4、修改testuser uid:4321,主組:root,輔助組:nobody,loginname:test,home:/home/test 家數據遷移
1
|
usermod -u 4321 -g 0 -G nobody -l test -md /home/test testuser |
5、批量創建帳號:user1…user10
uid:3000-3009,shell:/bin/csh,home:/testdir/username
passwd:usernamepass
注意家目錄相關配置,使用戶正常登錄
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
touch users .txt vi users .txt newusers users .txt touch passwd .txt vi passwd .txt cat passwd .txt |chpasswd cp -r /etc/skel/ .[^.]* /testdir/user1 cp -r /etc/skel/ .[^.]* /testdir/user2 cp -r /etc/skel/ .[^.]* /testdir/user3 cp -r /etc/skel/ .[^.]* /testdir/user4 cp -r /etc/skel/ .[^.]* /testdir/user5 cp -r /etc/skel/ .[^.]* /testdir/user6 cp -r /etc/skel/ .[^.]* /testdir/user7 cp -r /etc/skel/ .[^.]* /testdir/user8 cp -r /etc/skel/ .[^.]* /testdir/user9 cp -r /etc/skel/ .[^.]* /testdir/user10 |
原創文章,作者:NameLess,如若轉載,請注明出處:http://www.www58058.com/28169