#1、创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[root@haha ~]# groupadd g1
[root@haha ~]# useradd redhat
[root@haha ~]# touch /redhat.txt
[root@haha ~]# chown redhat:g1 /redhat.txt
[root@haha ~]# ll -d /redhat.txt
-rw-r--r--. 1 redhat g1 0 4月 26 20:19 /redhat.txt
#2、新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限
[root@haha ~]# mkdir /sc
[root@haha ~]# groupadd group
[root@haha ~]# chown :group /sc
[root@haha ~]# ll -d //sc
drwxr-xr-x. 2 root group 6 4月 26 20:23 //sc
[root@haha ~]# chmod o-x /sc
[root@haha ~]# ll -d /sc
drwxr-xr--. 2 root group 6 4月 26 20:23 /sc
[root@haha ~]# setfacl -m u:root:rwx /sc
[root@haha ~]# setfacl -m g:group:rwx /sc
[root@haha ~]# ll -d /sc
drwxrwxr--+ 2 root group 6 4月 26 20:23 /sc
[root@haha ~]# getfacl /sc
getfacl: Removing leading '/' from absolute path names
# file: sc
# owner: root
# group: group
user::rwx
user:root:-w-
group::r-x
group:group:rwx
mask::rwx
other::r--
#3、新建/cw目录为财务部存储目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup组中
[root@haha ~]# mkdir /cw
[root@haha ~]# groupadd mygroup
[root@haha ~]# chown :mygroup /cw
[root@haha ~]# ll -d /cw
drwxr-xr-x. 2 root mygroup 6 4月 26 20:31 /cw
[root@haha ~]# chmod g+w /cw
[root@haha ~]# ll -d /cw
drwxrwxr-x. 2 root mygroup 6 4月 26 20:31 /cw
[root@haha ~]# chmod g+s /cw
[root@haha ~]# ll -d /cw
drwxrwsr-x. 2 root mygroup 6 4月 26 20:31 /cw
#4、设置helen用户对于/sc和/cw目录可读、可写、可执行
[root@haha ~]# useradd helen
[root@haha ~]# setfacl -m u:helen:rwx /sc
[root@haha ~]# setfacl -m u:helen:rwx /cw
#5、设置/test目录为公共存储目录,对所有用户可以读、写、执行,但用户只能删除属于自己的文件。
[root@haha ~]# mkdir /test
[root@haha ~]# ll -d /test
drwxr-xr-x. 2 root root 6 4月 26 20:54 /test
[root@haha ~]# chmod 777 /test
[root@haha ~]# chmod o+t /test
[root@haha ~]# ll -d /test
drwxrwxrwt. 2 root root 6 4月 26 20:54 /test
#6、在/test/dir里创建的新文件自动属于temp组
[root@haha ~]# mkdir /test/dir
[root@haha ~]# groupadd temp
[root@haha ~]# chown :temp /test/dir
[root@haha ~]# ll -d /test/dir
drwxr-xr-x. 2 root temp 6 4月 26 20:56 /test/dir
[root@haha ~]# chmod o+w /test/dir/
[root@haha ~]# ll -d /test/dir
drwxr-xrwx. 2 root temp 6 4月 26 20:56 /test/dir
[root@haha ~]# chmod g+w /test/dir/
[root@haha ~]# ll -d /test/dir
drwxrwxrwx. 2 root temp 6 4月 26 20:56 /test/dir