RHCSA 基础练习

软/硬链接

1. 在test_dir目录下创建一个test_file.txt文件,然后再创建该文件的软链接链接名为soft_link.txt,再创建一个硬链接,链接名为hard_link.txt。

2. 删除test_file.txt文件,查看软链接和硬链接文件是否还能访问,分别说明原因。

软链接 soft_link.txt :无法访问
原因:软链接是文件路径的引用(类似快捷方式),仅记录原文件的路径。当原文件 test_file.txt 被删除后,软链接指向的路径失效,因此无法访问(会提示"没有那个文件或目录")。
硬链接 hard_link.txt :可以正常访问
原因:硬链接是原文件的"别名",与原文件共享同一个 inode (文件的唯一标识)和数据块。删除原文件只是减少了 inode 的引用计数,只要引用计数不为0(硬链接仍存在),文件数据就不会被删除,因此硬链接可以正常访问。

文件权限管理

1. 将copy_of_test.txt文件的所有者修改为当前系统中的普通用户user1(假设user1存在),文件所属组修改为group1(假设group1存在)。

**[root@localhost ~]# useradd user1

root@localhost \~\]# groupadd group1 \[root@localhost \~\]# touch copy_of_test.txt** **\[root@localhost \~\]# chown user1:group1 copy_of_test.txt** **​2. 为copy_of_test.txt文件设置权限,使得所有者有读写执行权限,所属组有读和执行权限,其他用户只有读权限,写出具体命令。** **\[root@localhost \~\]# chmod 754 copy_of_test.txt** **​3. 查看copy_of_test.txt文件的详细权限信息。** **\[root@localhost \~\]# ls -l copy_of_test.txt** ![](https://i-blog.csdnimg.cn/direct/c0b3c15736ad49e596e7b409967f9769.png) **用户和用户组基础操作** **1. 创建一个名为newuser1的普通用户,并指定其默认登录 Shell 为/bin/bash。** **\[root@localhost \~\]# useradd -s /bin/bash newuser1** **说明: -s 选项用于指定默认登录Shell。** **​2. 创建一个名为newgroup1的用户组,然后将newuser1添加到该用户组中。** **\[root@localhost \~\]# groupadd newgroup1 \[root@localhost \~\]# usermod -G newgroup1 newuser1** **3. 删除用户newuser1,要求保留其家目录。** **\[root@localhost \~\]# userdel newuser1** **说明:userdel 默认保留家目录;若需删除家目录,需加 -r 选项。** **文件和目录权限设置与修改** **​1. 在用户主目录下创建一个名为perm_test_dir的目录和perm_test_file.txt的文件,分别为该目录和文件设置权限:目录的所有者有读写执行权限,所属组有读和执行权限,其他用户无任何权限;文件的所有者有读写权限,所属组和其他用户只有读权限。** **\[root@localhost \~\]# mkdir perm_test_dir \[root@localhost \~\]# touch perm_test_file.txt \[root@localhost \~\]# chmod 750 perm_test_dir \[root@localhost \~\]# chmod 644 perm_test_file.txt** **​2. 将perm_test_dir目录及其下所有文件的所属组修改为newgroup1。** **\[root@localhost \~\]# chgrp -R newgroup1 perm_test_dir** **说明:-R 表示递归处理所有子文件/目录。** **​3. 递归地将perm_test_dir目录的权限修改为:所有者和所属组有读写执行权限,其他用户只有读权限。** **\[root@localhost \~\]# chmod -R 774 perm_test_dir** **写出通过dnf安装cockpit的详细过程** **\[root@localhost \~\]# mount /dev/sr0 /mnt** **\[root@localhost \~\]# vim /etc/yum.repos.d/base.repo** ![](https://i-blog.csdnimg.cn/direct/c38cced2dc4b48a9b6a444f073ec9f91.png) **保存后退出** ![](https://i-blog.csdnimg.cn/direct/aed5dd3dfd6c436897a78e087cf09dba.png) **\[root@localhost \~\]# systemctl stop firewalld** **\[root@localhost \~\]# vim /etc/cockpit/disallowed-users(删除root那行)** ![](https://i-blog.csdnimg.cn/direct/02f55ff6dd5e4e9f9b14763e9cac1ff6.png) **保存后退出 \[root@localhost \~\]# systemctl restart cockpit** **window浏览器访问 虚拟机ip地址:9090** ![](https://i-blog.csdnimg.cn/direct/6cc6cd25bc474a1a955f92d8d64d8309.png)

相关推荐
冷崖5 小时前
定时器的学习(二)
linux·c++·学习
馨谙5 小时前
chage -d 0 强制密码修改的完整流程
linux·运维
爱技术的小伙子5 小时前
【Linux运维】 Prometheus + Grafana + Alertmanager 监控系统部署指南(CentOS & Ubuntu 通用版)
linux·运维·prometheus
Zach_yuan5 小时前
Linux编辑器vim
linux·编辑器·vim
hweiyu006 小时前
Linux运维实战:云原生设计与实施Docker&K8S(视频教程)
linux·运维·云原生
海棠蚀omo6 小时前
Linux操作系统-命令行参数及环境变量
linux·操作系统
小白不想白a7 小时前
【shell】每日shell练习(系统用户安全审计/系统日志错误分析)
linux·运维·云原生
码猫Mrr7 小时前
创维E900V22D刷入armbian hdmi开机花屏和网络无法使用 解决方式【亲测】
linux·armbian·e900v22d
Cx330❀7 小时前
《Linux基础入门指令(二)》:从零开始理解Linux系统
linux·运维·服务器·网络·经验分享