用户和组的练习题

练习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

 

转载于:https://www.cnblogs.com/momenglin/p/8532538.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值