一:1、当用户redhat对/testdir目录无写权限时,该目录下的只读文件file1是否可修改和删除?
当用户redhat对/testdir目录无写权限时,该目录下的只读文件file1是不可以被修改和删除的。只有具有写权限的用户可以对目录中的文件进行修改和删除操作。
2、复制/etc/fstab文件到/var/tmp下,设置文件所有者为
redhat,有读写权限,所属组为cxk组,有读写权限,其他人无权限
(1)复制/etc/fstab文件到/var/tmp下,
[root@localhost ~]# cp /etc/fstab /var/tmp
(2)创建redhat的普通用户,并设置密码,
[root@localhost ~]# useradd redhat
[root@localhost ~]# passwd redhat
Changing password for user redhat.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
(3)创建cxk的组
[root@localhost ~]# groupadd cxk
(4)设置文件所有者为redhat,有读写权限,所属组为cxk组,有读写权限,其他人无权限
[root@localhost ~]# chown redhat.cxk /var/tmp/fstab
对于这个题,还有一些问题
3、要求在/tmp/testdir里创建的新文件自动属于g1组,组g2的成员如alice能对这些新文件有读写权限,组g3的成员如tom只能对新文件有读权限,其他用户(不属于g1,g2,g3)不能访问这个文件夹
[root@localhost ~]# groupadd g2
[root@localhost ~]# groupadd g3
[root@localhost ~]# useradd alice -g g2
[root@localhost ~]# useradd tom -g g3
[root@localhost ~]# mkdir -p /tmp/testdir
[root@localhost ~]# groupadd g1
[root@localhost ~]# chown :g1 /tmp/testdir
[root@localhost ~]# chmod g+s /tmp/testdir
[root@localhost ~]# chmod o-rwx /tmp/testdir
[root@localhost ~]# setfacl -d -m g:g2:rw /tmp/testdir
[root@localhost ~]# setfacl -d -m g:g3:r /tmp/testdir
[root@localhost ~]# setfacl -d -m o::- /tmp/testdir
[root@localhost ~]#
![](https://i-blog.csdnimg.cn/blog_migrate/d155049aefb403938235978bf7abfff7.png)
4.让普通用户有能力使用cat文件阅读/etc/shadow文件
[root@localhost ~]# setfacl -m u:redhat:r /etc/shadow
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ cat /etc/shadow
![](https://i-blog.csdnimg.cn/blog_migrate/8702eaee01300d422c42800356d52eb4.png)
5.创建/tmp/aaaa/目录,该目录中的文件只能文件拥有者可以删除
[redhat@localhost ~]$ mkdir -p /tmp/aaaa
[redhat@localhost ~]$ chmod 700 /tmp/aaaa