RHCSA学习第五天

1.新建一个名为 adminuser 的组,组 id 为40000

[root@localhost ~]# groupadd -g 40000 adminuser
[root@localhost ~]# cat /etc/group
root:x:0:
bin:x:1:
adminuser:x:40000:

2.新建一个名为 natasha 的用户,并将 adminuser 作为其附属组

[root@localhost ~]# useradd natasha -G adminuser
[root@localhost ~]# cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adminuser:x:40000:natasha
natasha:x:1001:

3.新建一个名为 harry 的用户,并将 adminuser 作为其附属组

[root@localhost ~]# useradd harry -G adminuser 
[root@localhost ~]# cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
adminuser:x:40000:natasha,harry
natasha:x:1001:
harry:x:1002:

4.新建一个名为 sarah 的用户,其不属于 adminuser 组,并将其 shell 设置为不可登 陆 shell / sbin / nologin 

[root@localhost ~]# useradd sarah -s /shell/sbin/nologin
[root@localhost ~]# id sarah
uid=1003(sarah) gid=1003(sarah) groups=1003(sarah)

5.添加用户 maomao ,修改它的家目录为/ maomao ,要求切换 maomao 时命令提示显示正常。

[root@localhost ~]# useradd maomao -d /maomao
[root@localhost ~]# cat /etc/passwd | grep maomao
maomao:x:1001:1001::/maomao:/bin/bash
[root@localhost ~]# su maomao
[maomao@localhost root]$ 

6.创建std1,std2两个组,要求std1组中有三个用户

[root@localhost ~]# groupadd -g std1 1000
groupadd: invalid group ID 'std1'
[root@localhost ~]# groupadd -g std1 2000
groupadd: invalid group ID 'std1'
[root@localhost ~]# groupadd std1 -g 2000
[root@localhost ~]# groupadd std2 -g 2001
[root@localhost ~]# gpasswd -a maomao std1
Adding user maomao to group std1
[root@localhost ~]# gpasswd -a harry std1
Adding user harry to group std1
[root@localhost ~]# gpasswd -a sarah std1
Adding user sarah to group std1
[root@localhost ~]# id harry
uid=1002(harry) gid=1002(harry) groups=1002(harry),40000(adminuser),2000(std1)
[root@localhost ~]# id sarah
uid=1003(sarah) gid=1003(sarah) groups=1003(sarah),2000(std1)
[root@localhost ~]# id maomao
uid=1004(maomao) gid=1004(maomao) groups=1004(maomao),2000(std1)

7.natasha、 harry 和 sarah 三个用户的密码均设置为 glegunge 创建用户(多种方式实现)

[root@localhost ~]# passwd harry
Changing password for user harry.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd sarah
Changing password for user sarah.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd natasha
Changing password for user natasha.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 

8.新建组, shengchan , caiwu , jishu 

[root@localhost ~]# groupadd shengchan
[root@localhost ~]# groupadd caiwu
[root@localhost ~]# groupadd jishu
[root@localhost ~]# cat /etc/group|grep caiwu
caiwu:x:40002:
[root@localhost ~]# cat /etc/group|grep jishu
jishu:x:40003:
[root@localhost ~]# cat /etc/group|grep shengchan
shengchan:x:40001:

9.新建用户要求如下:
* wjx 是 shengchan 组的附加用户

* liuy 是 caiwu 组的附加用户
* zxx 是 jishu 组的附加用户
*新建 admin 用户,此用户不属于以上提到的三个部门,以上用户密码设置为 redhat

[root@localhost ~]# useradd wjx -g /shengchan
useradd: group '/shengchan' does not exist
[root@localhost ~]# useradd wjx -g shengchan
[root@localhost ~]# useradd liuy -g caiwu
[root@localhost ~]# useradd zxx -g jishu
[root@localhost ~]# useradd admin
[root@localhost ~]# passwd admin
Changing password for user admin.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# id wjx
uid=1005(wjx) gid=40001(shengchan) groups=40001(shengchan)
[root@localhost ~]# id liuy
uid=1006(liuy) gid=40002(caiwu) groups=40002(caiwu)
[root@localhost ~]# id zxx
uid=1007(zxx) gid=40003(jishu) groups=40003(jishu)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北川Cc丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值