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)

相关推荐
q***471825 分钟前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch
Y淑滢潇潇1 小时前
RHCE 防火墙实验
linux·运维·rhce
wadesir2 小时前
当前位置:首页 > 服务器技术 > 正文Linux网络HSRP协议(实现路由器热备份与高可用性的实用指南)
linux·服务器·网络
稻谷君W2 小时前
Ubuntu 远程访问 Win11 WSL2 并固定访问教程
linux·运维·ubuntu
wdfk_prog2 小时前
[Linux]学习笔记系列 -- [kernel]workqueue
linux·笔记·学习
wdfk_prog2 小时前
[Linux]学习笔记系列 -- [kernel]usermode_helper
linux·笔记·学习
weixin_436525072 小时前
使用 idea 命令行构建 Docker 镜像并部署到云服务器
linux·docker·github
z***94844 小时前
Linux下安装Nginx服务及systemctl方式管理nginx详情
linux·运维·nginx
凉晓风5 小时前
Linux上TCP通信异常排查工具命令
linux·运维·tcp/ip
Xの哲學5 小时前
Linux 分区表深度技术剖析
linux·网络·算法·架构·边缘计算