一共六题,每一问题下为自己的解答(如有误敬请指正)
#1、创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[root@haixingjiaozhu ~]# groupadd g1
[root@haixingjiaozhu ~]# touch redhat.txt
[root@haixingjiaozhu ~]# chown redhat /root/redhat.txt
[root@haixingjiaozhu ~]# ll -d /root/redhat.txt
-rw-r--r--. 1 redhat g1 0 4月 26 20:17 /root/redhat.txt
[root@haixingjiaozhu ~]# chown -R redhat:g1 /root/redhat.txt
#2、新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限
[root@haixingjiaozhu ~]# mkdir /sc
[root@haixingjiaozhu ~]# chown -R root:group /sc
[root@haixingjiaozhu ~]# ll -d /sc
drwxr-sr-x. 2 root group 6 4月 25 19:27 /sc
[root@haixingjiaozhu ~]# setfacl -m g:group:rwx /sc
[root@haixingjiaozhu ~]# setfacl -m o:--- /sc
[root@haixingjiaozhu ~]# ll -d /sc
drwxrws---+ 2 root group 6 4月 25 19:27 /sc
#3、新建/cw目录为财务部存储目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup组中
[root@haixingjiaozhu ~]# mkdir /cw
[root@haixingjiaozhu ~]# groupadd mygroup
[root@haixingjiaozhu ~]# chown :group /cw
[root@haixingjiaozhu ~]# chmod g+w /cw
[root@haixingjiaozhu ~]# chmod g+s /cw
#4、设置helen用户对于/sc和/cw目录可读、可写、可执行
[root@haixingjiaozhu ~]# useradd helen
[root@haixingjiaozhu ~]# setfacl -m u:helen:rwx /sc /cw
#5、设置/test目录为公共存储目录,对所有用户可以读、写、执行,但用户只能删除属于自己的文件。
[root@haixingjiaozhu ~]# mkdir /test
[root@haixingjiaozhu ~]# chmod 777 /test
[root@haixingjiaozhu ~]# chmod o+t /test
[root@haixingjiaozhu ~]# ll -d /test
drwxrwxrwt. 3 root root 20 4月 8 18:20 /test
#6、在/test/dir里创建的新文件自动属于temp组
[root@haixingjiaozhu ~]# groupadd temp
[root@haixingjiaozhu ~]# mkdir /test/dir
[root@haixingjiaozhu ~]# chown :temp /test/dir/
[root@haixingjiaozhu ~]# chmod o+w /test/dir/
[root@haixingjiaozhu ~]# chmod g+s /test/dir/
[root@haixingjiaozhu ~]# ll -d /test/dir/
drwxr-srwx. 2 root temp 6 4月 26 20:24 /test/dir/