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
用户和用户组基础操作
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
保存后退出
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# vim /etc/cockpit/disallowed-users(删除root那行)
保存后退出
[root@localhost ~]# systemctl restart cockpit
window浏览器访问 虚拟机ip地址:9090