#1、创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[root@localhost ~]# groupadd g1
groupadd:“g1”组已存在
[root@localhost ~]# touch /redhat.txt
[root@localhost ~]# ll -d /
dr-xr-xr-x. 23 root root 4096 5月 7 16:01 /
[root@localhost ~]# ll /root/ -d
dr-xr-x---. 14 root root 4096 5月 7 15:54 /root/
[root@localhost ~]# touch /root/redhat.txt
[root@localhost ~]# ll /root/redhat.txt
-rw-r--r--. 1 root root 0 5月 7 16:05 /root/redhat.txt
[root@localhost ~]# chown redhat:g1 /root/redhat.txt
#2、新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限
[root@localhost ~]# mkdir /sc
[root@localhost ~]# groupadd group
[root@localhost ~]# ll -d /sc
drwxrwx---. 2 root group 6 4月 27 16:41 /sc
setfacl -m g:group:rwx /sc
[root@localhost ~]# setfacl -m o:--- /sc
#3、新建/cw目录为财务部存储目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup组中
[root@localhost ~]# mkdir /cw
[root@localhost ~]# ll -d /cw
drwxr-xr-x. 2 root root 6 5月 7 16:30 /cw
[root@localhost ~]# groupadd mygroup
[root@localhost ~]# chown :mygroup /cw
[root@localhost ~]# ll -d /cw
drwxr-xr-x. 2 root mygroup 6 5月 7 16:30 /cw
[root@localhost ~]# chmod g+w /cw
[root@localhost ~]# ll -d /cw
drwxr-xr-x. 2 root mygroup 6 5月 7 16:30 /cw
[root@localhost ~]# chmod g+s /cw
[root@localhost ~]# ll -d /cw
drwxr-sr-x. 2 root mygroup 6 5月 7 16:30 /cw
[root@localhost ~]# gpasswd -M wukong.wujing.wuneng mygroup
[root@localhost ~]# touch /cw/file2
#4、设置helen用户对于/sc和/cw目录可读、可写、可执行
[root@localhost ~]# useradd helen
[root@localhost ~]# setfacl -m u:helen:rwx /sc
[root@localhost ~]# setfacl -m u:helen:rwx /cw
#5、设置/test目录为公共存储目录,对所有用户可以读、写、执行,但用户只能删除属于自己的文件。
[root@localhost ~]# mkdir /test
[root@localhost ~]# ll /test
总用量 0
[root@localhost ~]# ll /test -d
drwxr-xr-x. 2 root root 6 5月 7 16:48 /test
[root@localhost ~]# chmod 777 /test/
[root@localhost ~]# ll /test -d
drwxrwxrwx. 2 root root 6 5月 7 16:48 /test
[root@localhost ~]# chmod o+t /test/
[root@localhost ~]# ll /test -d
drwxrwxrwt. 2 root root 6 5月 7 16:48 /test
[root@localhost ~]# touch /test/1
#6、在/test/dir里创建的新文件自动属于temp
[root@localhost ~]# mkdir /test/dir
[root@localhost ~]# ll /test/dir/ -d
drwxr-xr-x. 2 root root 6 5月 7 16:57 /test/dir/
[root@localhost ~]# groupadd temp
[root@localhost ~]# chown :temp /test/dir/
[root@localhost ~]# touch /test/dir/1
[root@localhost ~]# chmod o+w /test/dir/
[root@localhost ~]# chmod g+s /test/dir/
[root@localhost ~]# ll -d /test/dir/
drwxr-s-w-. 2 root temp 15 5月 7 17:03 /test/dir/