From 3bdb4dc588409fa0828ab6f998013292087a5a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B4=8B?= <3384197154@qq.com> Date: Sat, 15 Jun 2024 23:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\347\220\206\346\235\203\351\231\220.md" | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 "\346\235\250\346\264\213/20240615\346\226\207\344\273\266\347\256\241\347\220\206\346\235\203\351\231\220.md" diff --git "a/\346\235\250\346\264\213/20240615\346\226\207\344\273\266\347\256\241\347\220\206\346\235\203\351\231\220.md" "b/\346\235\250\346\264\213/20240615\346\226\207\344\273\266\347\256\241\347\220\206\346\235\203\351\231\220.md" new file mode 100644 index 0000000..dc5b981 --- /dev/null +++ "b/\346\235\250\346\264\213/20240615\346\226\207\344\273\266\347\256\241\347\220\206\346\235\203\351\231\220.md" @@ -0,0 +1,185 @@ +### 权限管理练习 + +1. 创建/guanli 目录,在/guanli下创建zonghe 和 jishu 两个目录(一条命令) + + ``` + mkdir guanli/zonghe guanli/jishu + + ``` + + + +2. 添加组帐号zonghe、caiwu、jishu,GID号分别设置为2001、2002、2003 + + ``` + groupadd -g 2001 zonghe ;groupadd -g 2002 caiwu ;groupadd -g 2003 jishu + + ``` + + + +3. 创建jerry、kylin、tsengia、obama用户,其中的kylin用户帐号在2020年12月30日后失效 + + ``` + useradd -m -s /guanli jerry + chage -E '2020-12-30' kylin + + ``` + + + +4. 将jerry、kylin、tsengia、obama等用户添加到zonghe组内 + + ``` + usermod -G zonghe obama + + ``` + + + +5. 创建handy、cucci用户,其中cucci帐号的登录Shell设置为“/sbin/nologin” + + ``` + useradd -m -s /bin/bash cucci + usermod -s /sbin/nologin cucci + + ``` + + + +6. 将handy、cucci等用户添加到jishu组内 + + ``` + usermod -G jishu cucci + usermod -G jishu handy + + ``` + + + +7. 将上述的所有用户均要求加入到guanli组内 + + ``` + usermod -G guanli tsengia + + ``` + + + +8. 将zonghe组内的obama用户删除 + + ``` + gpasswd -d obama zonghe + + ``` + + + +9. 为jerry用户设置密码为“123456”(使用普通方法)为cucci用户设置密码为“redhat” + + ``` + passwd cucci + New password: + Retype new password: + passwd: password updated successfully + + ``` + + + +10. 将jerry用户锁定,并查看锁定状态 + + ``` + usermod -L jerry usermod -L jerry | passwd -S jerry + jerry L 06/15/2024 0 99999 7 -1 + + ``` + + + +11. 打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个 + + ``` + fuser -k -i + ``` + + + +12. 查看cucci用户,属于那些组,并查看其详细信息 + + ``` + cat /etc/group | grep 'cucci' + + ``` + + + +13. 手工创建账号student(预留) + + ``` + useradd -m /bin/bash student + ``` + + + +14. 设置权限及归属:/guanli目录属组设为guanli, /guanli/zonghe目录的属组设为zonghe /guanli/jishu目录的属组设为jishu,设置3个目录都是禁止其他用户访问的权限 + + ``` + chown /guanli/zonghe zonghe + chmod o+1,o+2,o+4 jishu + ``` + + + +15. 建立公共目录/ceshi允许技术组内的所有用户读取、写入、执行文件, 禁止其他用户读、写、执行 + + ``` + chmod u+r,u+w,u+x ceshi + + ``` + + + +16. 清除jerry用户密码 + + ``` + passwd -d jerry + ``` + + + +17. 锁定cucci用户密码并查看状态 + + ``` + usermod -L cucci usermod -L jerry | passwd -S cucci + ``` + + + +18. 修改obama用户的UID为8888 + + ``` + usermod -u 888 obama + + ``` + + + +19. 通过passwd命令修改kylin用户的最长密码使用期限为60天 + + ``` + passwd -x 60 kylin + ``` + + + +20. 通过id groups等命令查看用户handy信息 + +``` + groups handy +handy : handy guanli + + id handy +uid=1005(handy) gid=1005(handy) groups=1005(handy),2004(guanli) +``` + -- Gitee