1、
[root@localhost ~]# groupadd g1
groupadd:“g1”组已存在
[root@localhost ~]# touch /root/redhat.txt
[root@localhost ~]# ll /root/redhat.txt
-rw-r--r--. 1 root root 0 5月 5 13:42 /root/redhat.txt
[root@localhost ~]# chown redhat:g1 /root/redhat.txt
chown: 无效的用户: “redhat:g1”
[root@localhost ~]# useradd redhat
[root@localhost ~]# chown redhat:g1 /root/redhat.txt
[root@localhost ~]# ll /root/redhat.txt
-rw-r--r--. 1 redhat g1 0 5月 5 13:42 /root/redhat.txt
2、
[root@localhost ~]# mkdir -pv /sc
mkdir: 已创建目录 '/sc'
[root@localhost ~]# groupadd group
[root@localhost ~]# ll -d /sc
drwxr-xr-x. 2 root root 6 5月 5 13:46 /sc
[root@localhost ~]# setfacl -m g:group:rwx /sc
[root@localhost ~]# setfacl -m o:--- /sc
3、
[root@localhost ~]# mkdir /cw
[root@localhost ~]# groupadd mygroup
[root@localhost ~]# chown :mygroup /cw
[root@localhost ~]# ll -d /cw
drwxr-xr-x. 2 root mygroup 6 5月 5 13:48 /cw
[root@localhost ~]# chmod g+w /cw
[root@localhost ~]# ll -d /cw
drwxrwxr-x. 2 root mygroup 6 5月 5 13:48 /cw
[root@localhost ~]# chmod g+s /cw
[root@localhost ~]# ll -d /cw
drwxrwsr-x. 2 root mygroup 6 5月 5 13:48 /cw
[root@localhost ~]# useradd wukong
[root@localhost ~]# useradd wujing
[root@localhost ~]# useradd wuneng
[root@localhost ~]# gpasswd -M wukong,wujing,wuneng, mygroup
[root@localhost ~]# touch /cw/file2
[root@localhost ~]# su - wukong
[wukong@localhost ~]$ touch /cw/file1
[wukong@localhost ~]$ ll /cw
总用量 0
-rw-r--r--. 1 wukong mygroup 0 5月 5 13:53 file1
-rw-r--r--. 1 root mygroup 0 5月 5 13:52 file2
4、
[root@localhost ~]# useradd helen
[root@localhost ~]# setfacl -m u:helen:rwx /sc
[root@localhost ~]# setfacl -m u:helen:rwx /cw
5、
[root@localhost ~]# mkdir -pv /test
mkdir: 已创建目录 '/test'
[root@localhost ~]# ll /test
总用量 0
[root@localhost ~]# ll /test -d
drwxr-xr-x. 2 root root 6 5月 5 13:59 /test
[root@localhost ~]# chmod 777 /test/
[root@localhost ~]# chmod o+t /test/
[root@localhost ~]# ll /test -d
drwxrwxrwt. 2 root root 6 5月 5 13:59 /test
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ touch /test/2
[redhat@localhost ~]$ rm -rf /test/2
6、
[root@localhost ~]# mkdir -pv /test/dir
mkdir: 已创建目录 '/test/dir'
[root@localhost ~]# ll /test/dir/-d
ls: 无法访问 '/test/dir/-d': 没有那个文件或目录
[root@localhost ~]# ll /test/dir/ -d
drwxr-xr-x. 2 root root 6 5月 5 14:05 /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-srwx. 2 root temp 15 5月 5 14:06 /test/dir
[root@localhost ~]# su - redhat
[redhat@localhost ~]$ touch /test/dir/4
[redhat@localhost ~]$ ll /test/dir/
总用量 0
-rw-r--r--. 1 root root 0 5月 5 14:06 1
-rw-r--r--. 1 redhat temp 0 5月 5 14:07 4
[redhat@localhost ~]$ exit
注销
[root@localhost ~]# ll /test/dir/
总用量 0
-rw-r--r--. 1 root root 0 5月 5 14:06 1
-rw-r--r--. 1 redhat temp 0 5月 5 14:07 4
[root@localhost ~]# su - helen
[helen@localhost ~]$ touch /test/dir/5
[helen@localhost ~]$ ll /test/dir/
总用量 0
-rw-r--r--. 1 root root 0 5月 5 14:06 1
-rw-r--r--. 1 redhat temp 0 5月 5 14:07 4
-rw-r--r--. 1 helen temp 0 5月 5 14:09 5