#1,创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[root@hahaha ~]#groupadd g1
[root@hahaha ~]# gpasswd g1 -a talentman
Adding user talentman to group g1
[root@hahaha ~]# touch /redhat.txt
[root@hahaha ~]# chown :g1 /redhat.txt
[root@hahaha ~]# ll /redhat.txt
-rw-r--r--. 1 talentman g1 0 May 7 19:55 /redhat.txt
#2,新建/sc目录,所属组为group组,root用户和group用户可以在该目录下创建文件,其他人无任何权限
[root@hahaha ~]# mkdir /sc
[root@hahaha ~]# groupadd group
[root@hahaha ~]# chown :group /sc
[root@hahaha ~]# chmod g+w /sc
[root@hahaha ~]# ll -d /sc
drwxrwxr-x. 2 root group 6 Apr 25 19:32 /sc
[root@hahaha ~]# chmod 770 /sc
[root@hahaha ~]# ll -d /sc
drwxrwx---. 2 root group 6 Apr 25 19:32 /sc
#3,新建/cw目录视为财务部储存目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup中
[root@hahaha ~]# mkdir /cw
[root@hahaha ~]# groupadd mygroup
[root@hahaha ~]# useradd zhangsan
[root@hahaha ~]# useradd lisi
[root@hahaha ~]# gpasswd -M zhangsan,lisi mygroup
[[roothahaha ~]# su - zhangsan
[zhangsan@hahaha ~]$ touch /cw/file1
touch: cannot touch '/cw/file1': Permission denied
[root@hahaha ~]# chmod 770 /cw
[root@hahaha ~]# ll -d /cw
drwxrwx---. 2 root mygroup 6 May 7 20:33 /cw
[root@hahaha ~]# su - zhangsan
-bash: /etc/profile: line 82: syntax error: unexpected end of file
-bash: alias: hello: not found
-bash: alias: =/usr/bin/hello: not found
[zhangsan@hahaha ~]$ touch /cw/file4
[zhangsan@hahaha ~]$
[zhangsan@hahaha ~]$ ll /cw
total 0
-rw-r--r--. 1 lisi lisi 0 May 7 20:48 file1
-rw-r--r--. 1 zhangsan zhangsan 0 May 7 20:51 file2
-rw-r--r--. 1 zhangsan zhangsan 0 May 7 21:30 file4
#4,设置helen用户对于/sc和/cw目录可读,可写,可执行
[root@hahaha ~]# useradd helen
[root@hahaha ~]# setfacl -m u:helen:rwx /sc
[root@hahaha ~]# getfacl /sc
getfacl: Removing leading '/' from absolute path names
# file: sc
# owner: root
# group: group
user::rwx
user:helen:rwx
group::rwx
mask::rwx
other::---
[root@hahaha ~]# setfacl -m u:helen:rwx /cw
[root@hahaha ~]# getfacl /cw
getfacl: Removing leading '/' from absolute path names
# file: cw
# owner: root
# group: mygroup
user::rwx
user:helen:rwx
group::rwx
mask::rwx
other::---
#5,设置/test目录为公共储存目录可读,对所有用户可以读,写,执行,但用户只能删除属于自己的文件。
[root@hahaha ~]# touch /test
[root@hahaha ~]# chmod 777 /test
[root@hahaha ~]# ll -d /test
drwxrwxrwx. 3 root root 21 May 7 22:09 /test
[root@hahaha ~]# su - helen
[helen@hahaha ~]$ touch /test/file1
[helen@hahaha ~]$ su - talentman
[talentman@hahaha ~]$ touch /test/file2
[talentman@hahaha ~]$ ll /test
total 0
drwxr-xr-x. 2 root root 45 Apr 9 19:12 class01
-rw-r--r--. 1 helen helen 0 May 7 22:12 file1
-rw-r--r--. 1 talentman talentman 0 May 7 22:12 file2
[talentman@hahaha ~]$ rm -f /test/file1
rm: cannot remove '/test/file1': Operation not permitted
[talentman@hahaha ~]$ rm -f /test/file2
[talentman@hahaha ~]$ ll /test
total 0
drwxr-xr-x. 2 root root 45 Apr 9 19:12 class01
-rw-r--r--. 1 helen helen 0 May 7 22:12 file1
#6,在/test/dir里创建的新文件自动属于与temp组
[talentman@hahaha ~]$ mkdir /test/dir
[talentman@hahaha ~]$ chmod g+s /test/di
[talentman@hahaha ~]$ ll -d /test/dir
drwxr-sr-x. 2 talentman talentman 6 May 7 22:26 /test/dir
talentman@hahaha ~]$ chmod o+w /test/dir
[talentman@hahaha ~]$ ll -d /test/dir
drwxr-srwx. 2 talentman talentman 6 May 7 22:26 /test/dir
[root@hahaha ~]# groupadd temp
[root@hahaha ~]# chown :temp /test/dir
[root@hahaha ~]# su - wukong
-bash: /etc/profile: line 82: syntax error: unexpected end of file
-bash: alias: hello: not found
-bash: alias: =/usr/bin/hello: not found
[wukong@hahaha ~]$ touch /test/dir/1
[root@hahaha ~]# su - helen
-bash: /etc/profile: line 82: syntax error: unexpected end of file
-bash: alias: hello: not found
-bash: alias: =/usr/bin/hello: not found
[helen@hahaha ~]$ touch /test/dir/2
[helen@hahaha ~]$ ll /test/dir
total 0
-rw-r--r--. 1 wukong temp 0 May 7 22:35 1
-rw-r--r--. 1 helen temp 0 May 7 22:36 2