用户和组的练习题

练习1

创建用户gentoo,附加组为binroot,默认shell为 /bin/csh,注释信息为”Gentoo Distribution”

1
2
3
[root❄centos7 skel]☭ useradd gentoo -G bin,root -s /bin/csh -c "Gentoo Distribution"
[root❄centos7 skel]☭ cat /etc/passwd |grep gentoo
gentoo:x:1001:1001:Gentoo Distribution:/home/gentoo:/bin/csh

练习2

创建下面的用户、组和组成员关系

名字为admins 的组

用户natasha,使用admins 作为附属组

用户harry,也使用admins 作为附属组

用户sarah,不可交互登录系统,且不是admins 的成员, natashaharrysarah密码都是centos

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root❄centos7 skel]☭ groupadd admins
[root❄centos7 skel]☭ useradd natasha -G admins
[root❄centos7 skel]☭ useradd harry -G admins
[root❄centos7 skel]☭ useradd sarah -s /sbin/nologin
[root❄centos7 skel]☭ echo centos | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root❄centos7 skel]☭ echo centos | passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root❄centos7 skel]☭ echo centos | passwd --stdin sarah
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
 
[root❄centos7 skel]☭ tail -n 3 /etc/passwd
natasha:x:1002:1003::/home/natasha:/bin/bash
harry:x:1003:1004::/home/harry:/bin/bash
sarah:x:1004:1005::/home/sarah:/sbin/nologin

 

posted @ 2018-03-09 10:35  莫孟林  阅读(297)  评论(0编辑  收藏  举报