(1)创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
具体步骤如下:
groupadd g1 创建g1组
useradd redhat 创建用户
mkdir redhat 创建目录
touch redhat.txt 在目录下创建redhat.txt文件
chown redhat redhat.txt 让该文件所属于redhat用户
chgrp g1 ./redhat.txt 改变所属组
(2)新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限
mkdir /sc 创建目录
groupadd -r group 创建组
chgrp group /sc 改变所属组
chmod -R 770 /sc 改变权限
(3)新建/cw目录为财务部存储目录,只能对财务部人员可以写入,并且财务部人员所建立的文件都自动属于mygroup组中
mkdir /cw
groupadd mygroup
chgrp mygroup /cw
chmod 774 /cw
(4)设置 helen用户对于/sc和/cw目录可以读,写,执行
setfacl -m u:helen:rwx /sc
setfacl -m u:helen:rwx /cw
(5)设置/test目录为公共存储目录对所有用户可以读,写,执行,但用户只能删除属于自己的文件(t权限)
chmod o+wrx /test
chmod a+t /test
[root@server1 ~]# ll -d /test
drwxr-xrwt. 146 root root 8192 Oct 29 01:00 /test
(6)在/test/dir里创建的新文件自动属于temp组
[root@server1 ~]# cd /test
[root@server1 test]# mkdir /dir
[root@server1 test]# chown :temp /test/dir
[root@server1 test]# ll -d /test/dir
drwxr-xr-x. 2 root temp 37 Oct 29 00:18 /test/dir
[root@server1 test]# chmod g+s /test/dir
[root@server1 test]# ll -d /test/dir
drwxr-sr-x. 2 root temp 37 Oct 29 00:18 /test/dir