1、新建目录要求如下:
(1)/pub目录为公共存储目录对所有用户可以读,写,执行,但用户只能删除属于自己的文件(t权限)
[root@haha ~]# mkdir /pub
mkdir: 无法创建目录"/pub": 文件已存在
[root@haha ~]# cd /pub
[root@haha pub]# ll -d
drwxrwxrwx. 2 root root 29 7月 31 16:19 .
[root@haha pub]# chown 777 .
[root@haha pub]# chmod o+t .
[root@haha pub]# su - kun
上一次登录:五 8月 5 14:57:56 CST 2022pts/1 上
[kun@haha ~]$ rm -f kun
(2)/sc目录为生产部存储目录只能对生产部人员可以写入,并且生产部人员该目录所建立的文件都自动归属到shengchan中
[root@haha ~]# mkdir /sc
[root@haha ~]# cd /sc
[root@haha sc]# ll
总用量 0
[root@haha sc]# ll -d
drwxr-xr-x. 2 root root 6 8月 5 15:06 .
[root@haha sc]# groupadd shengchan
[root@haha sc]# ll -d /sc
drwxr-xr-x. 2 root root 6 8月 5 15:06 /sc
[root@haha sc]# chown :shengchan /sc
[root@haha sc]# ll -d /sc
drwxr-xr-x. 2 root shengchan 6 8月 5 15:06 /sc
[root@haha sc]# chmod 770 /sc
[root@haha sc]# ll -d
drwxrwx---. 2 root shengchan 6 8月 5 15:06 .
[root@haha sc]# chmod g+s /sc
[root@haha sc]# ll -d /sc
drwxrws---. 2 root shengchan 6 8月 5 15:06 /sc
(3)/cw目录为财务部存储目录只能对财务部人员可以写入并且财务部人员所建立的文件都自动属于caiwu组中
[root@haha ~]# mkdir /cw
[root@haha ~]# cd /cw
[root@haha cw]# ll -d
drwxr-xr-x. 2 root root 6 8月 5 15:15 .
[root@haha cw]# groupadd caiwu
[root@haha cw]# chown :caiwu /sc
[root@haha cw]# ll -d /sc
drwxrws---. 2 root caiwu 6 8月 5 15:06 /sc
[root@haha cw]# chmod g+s /sc
[root@haha cw]# ll -d /sc
drwxrws---. 2 root caiwu 6 8月 5 15:06 /sc
(4)admin用户对于/sc和/cw目录可以读,写,执行
[root@haha cw]# useradd admin
[root@haha cw]# ll -d /cw /sc
drwxr-xr-x. 2 root root 6 8月 5 15:15 /cw
drwxrws---. 2 root caiwu 6 8月 5 15:06 /sc
[root@haha cw]# id admin
uid=1005(admin) gid=1007(admin) 组=1007(admin)
[root@haha cw]# chown admin /sc
[root@haha cw]# setfacl -m u=admin:rwx /cw
测试
[root@haha cw]# ll -d /cw /sc
drwxr-xr-x. 2 admin root 6 8月 5 15:15 /cw
drwxrws---. 2 admin caiwu 6 8月 5 15:06 /sc
[root@haha cw]# su - admin
上一次登录:五 8月 5 15:19:54 CST 2022pts/1 上
[admin@haha ~]$ cd /cw
[admin@haha cw]$ ll
总用量 0
[admin@haha cw]$ touch admin
[admin@haha cw]$ ll
总用量 0
-rw-rw-r--. 1 admin admin 0 8月 5 15:24 admin
[admin@haha cw]$ cd /sc
[admin@haha sc]$ ll
总用量 0
[admin@haha sc]$ touch admin
[admin@haha sc]$ ll
总用量 0
-rw-rw-r--. 1 admin caiwu 0 8月 5 15:24 admin