1.在/home中创建一个名为 file1.txt 的文件,并设置权限为:所有者和组成员可以读写,但其他人只能读。
2.在 /home 目录下创建一个名为 shared 的子目录,使得所有用户都可以进入,读,写,该目录中文件。
3.在/home中创建一个file2.txt,添加不可修改文件属性。
4.给cat命令添加suid权限,使得普通用户可以使用cat查看/etc/shadow文件。
5.给file2.txt添加acl权限让redhat不可该文件做任何操作
6.删除file2.txt的扩展权限
答案:
[root@rhcsa ~]# touch file1.txt
[root@rhcsa ~]# chmod ug=rw,o=r file1.txt
[root@rhcsa ~]# ll file1.txt
-rw-rw-r--. 1 root root 0 11月 27 16:50 file1.txt
[root@rhcsa ~]# mkdir shared
[root@rhcsa ~]# chmod 777 shared
[root@rhcsa ~]# chmod -R 777 shared
[root@rhcsa ~]# touch file2.txt
[root@rhcsa ~]# chattr +i file2.txt
[root@rhcsa ~]# rm -rf file2.txt
rm: 无法删除 'file2.txt': 不允许的操作
[root@rhcsa ~]# chattr -i file2.txt
[root@rhcsa ~]# chmod u+s /bin/cat
[root@rhcsa ~]# ll /bin/cat
-rwsr-xr-x. 1 root root 36520 1月 29 2024 /bin/cat
[root@rhcsa ~]# setfacl -m u:redhat:--- file2.txt
setfacl: Option -m: 无效的参数 near character 3
[root@rhcsa ~]# setfacl -m u:red:--- file2.txt
[root@rhcsa ~]#
[root@rhcsa ~]# setfacl -x u:red:--- file2.txt
setfacl: Option -x: 无效的参数 near character 7
[root@rhcsa ~]# setfacl -x u:red file2.txt
[root@rhcsa ~]# setfacl -b file2.txt