一、实验目的

(1)管理组群
(2)使用用户管理器管理用户和组群

二、实验内容

1、添加一个组号为1005名字为grouptest的组群

  1. [root@centos-linux home]# groupadd -g1005 grouptest
  2. [root@centos-linux home]#

2、把user1用户加入grouptest组,并指派user1为管理员

  1. [root@centos-linux ~]# gpasswd -a user1 grouptest
  2. 正在将用户“user1”加入到“grouptest”组中
  3. [root@centos-linux ~]# gpasswd -A user1 grouptest
  4. [root@centos-linux ~]#

3、修改grouptest组标识符为1016,名字修改为testgroup

  1. [root@centos-linux ~]# groupmod -g 1016 -n testgroup grouptest
  2. [root@centos-linux ~]# tail -3 /etc/group
  3. group1:x:1001:
  4. user1:x:1006:
  5. testgroup:x:1016:user1

4、删除testgroup组

  1. [root@centos-linux ~]# groupdel testgroup
  2. groupdel:不能移除用户“grouptest”的主组
  3. [root@centos-linux ~]# id grouptest
  4. uid=1002(grouptest) gid=1016(testgroup) 组=1016(testgroup)
  5. [root@centos-linux ~]# userdel grouptest
  6. [root@centos-linux ~]# groupdel testgroup
  7. [root@centos-linux ~]# tail -3 /etc/group
  8. named:x:25:
  9. group1:x:1001:
  10. user1:x:1006:
  11. [root@centos-linux ~]#

5、安装system-config-users工具

  1. [root@centos-linux opt]# yum install system-config-user -y
  2. 已加载插件:fastestmirror, langpacks
  3. Loading mirror speeds from cached hostfile
  4. 没有可用软件包 system-config-user
  5. 错误:无须任何处理
  6. [root@centos-linux opt]# yum install system-config-users -y
  7. 已加载插件:fastestmirror, langpacks
  8. Loading mirror speeds from cached hostfile
  9. 正在解决依赖关系
  10. --> 正在检查事务
  11. ---> 软件包 system-config-users.noarch.0.1.3.5-2.el7 将被 安装
  12. --> 正在处理依赖关系 system-config-users-docs,它被软件包 system-config-users-1.3.5-2.el7.noarch 需要
  13. --> 正在检查事务
  14. ---> 软件包 system-config-users-docs.noarch.0.1.0.9-6.el7 将被 安装
  15. --> 正在处理依赖关系 rarian-compat,它被软件包 system-config-users-docs-1.0.9-6.el7.noarch 需要
  16. --> 正在检查事务
  17. ---> 软件包 rarian-compat.x86_64.0.0.8.1-11.el7 将被 安装
  18. --> 正在处理依赖关系 rarian = 0.8.1-11.el7,它被软件包 rarian-compat-0.8.1-11.el7.x86_64 需要
  19. --> 正在处理依赖关系 rarian,它被软件包 rarian-compat-0.8.1-11.el7.x86_64 需要
  20. --> 正在处理依赖关系 librarian.so.0()(64bit),它被软件包 rarian-compat-0.8.1-11.el7.x86_64 需要
  21. --> 正在检查事务
  22. ---> 软件包 rarian.x86_64.0.0.8.1-11.el7 将被 安装
  23. --> 解决依赖关系完成
  24. 依赖关系解决
  25. ==============================================================================================================
  26. Package 架构 版本 大小
  27. ==============================================================================================================
  28. 正在安装:
  29. system-config-users noarch 1.3.5-2.el7 centos 337 k
  30. 为依赖而安装:
  31. rarian x86_64 0.8.1-11.el7 centos 98 k
  32. rarian-compat x86_64 0.8.1-11.el7 centos 66 k
  33. system-config-users-docs noarch 1.0.9-6.el7 centos 308 k
  34. 事务概要
  35. ==============================================================================================================
  36. 安装 1 软件包 (+3 依赖软件包)
  37. 总下载量:809 k
  38. 安装大小:3.9 M
  39. Downloading packages:
  40. --------------------------------------------------------------------------------------------------------------
  41. 总计 2.5 MB/s | 809 kB 00:00:00
  42. Running transaction check
  43. Running transaction test
  44. Transaction test succeeded
  45. Running transaction
  46. 警告:RPM 数据库已被非 yum 程序修改。
  47. 正在安装 : rarian-0.8.1-11.el7.x86_64 1/4
  48. 正在安装 : rarian-compat-0.8.1-11.el7.x86_64 2/4
  49. 正在安装 : system-config-users-1.3.5-2.el7.noarch 3/4
  50. 正在安装 : system-config-users-docs-1.0.9-6.el7.noarch 4/4
  51. 验证中 : rarian-compat-0.8.1-11.el7.x86_64 1/4
  52. 验证中 : system-config-users-1.3.5-2.el7.noarch 2/4
  53. 验证中 : rarian-0.8.1-11.el7.x86_64 3/4
  54. 验证中 : system-config-users-docs-1.0.9-6.el7.noarch 4/4
  55. 已安装:
  56. system-config-users.noarch 0:1.3.5-2.el7
  57. 作为依赖被安装:
  58. rarian.x86_64 0:0.8.1-11.el7 rarian-compat.x86_64 0:0.8.1-11.el7
  59. system-config-users-docs.noarch 0:1.0.9-6.el7
  60. 完毕!
  61. [root@centos-linux opt]# rpm -q system-config-users
  62. system-config-users-1.3.5-2.el7.noarch
  63. [root@centos-linux opt]#

6、使用“用户管理器”执行添加user1和user2用户和grouptest组群、编辑用户或组群的属性、删除用户或组群、加入或退出组群等操作。
image.png

三、实验作业

使用命令和用户管理器两种方式实现下列操作:
1、添加用户:添加用户(以自己的名字命名)

  1. [root@centos-linux opt]# useradd cyy1

2、为用户设置密码:passwd 123,输入两次密码(密码不会被显示出来)。

  1. [root@centos-linux opt]# passwd cyy1
  2. 更改用户 cyy1 的密码
  3. 新的 密码:
  4. 无效的密码: 密码未通过字典检查 - 过于简单化/系统化
  5. 重新输入新的 密码:
  6. passwd:所有的身份验证令牌已经成功更新。

3、添加组(以自己的名字命名)

  1. [root@centos-linux opt]# groupadd cyytest

4、把用户加入到组

  1. [root@centos-linux opt]# gpasswd -a cyy1 cyytest
  2. 正在将用户“cyy1”加入到“cyytest”组中

5、删除用户

  1. [root@centos-linux opt]# userdel cyy1
  2. [root@centos-linux opt]# tail -2 /etc/passwd
  3. named:x:25:25:Named:/var/named:/sbin/nologin
  4. user1:x:1001:1006::/home/user1:/bin/bash

6、删除组

  1. [root@centos-linux opt]# groupdel cyytest
  2. [root@centos-linux opt]# tail -2 /etc/group
  3. group1:x:1001:
  4. user1:x:1006:
  5. [root@centos-linux opt]#