1)/home/tools的所有组是admins
2)此目录能被admins组的成员读取、写入和访问,除root外其他用户没有这些权限
3)在此目录下创建的文件,其组的所有权自动设置为admins组
首先我们需要创建一个/home/tools的目录
[root@bianchengshe ~]# mkdir /home/tools #创建目录
[root@servera ~]# ls -ld /home/tools/ #查看目录
drwxr-xr-x. 2 root root 6 Sep 5 23:29 /home/tools/
把/home/tools拥有组设置为admins
[root@bianchengshe ~]# chgrp admins /home/tools #设置目录拥有组权限
[root@bianchengshe ~]# ls -ld /home/tools/ #查看目录权限
drwxr-xr-x. 2 root admins 6 Sep 5 23:29 /home/tools/
此目录能被admins组的成员读取、写入和访问,除root外其他用户没有这些权限
[root@bianchengshe ~]# chmod g+w,o-rx /home/tools/ #拥有组增加w权限,其他人设置减少所有权限
[root@bianchengshe ~]# ls -ld /home/tools/ #查看权限
drwxrwx---. 2 root admins 6 Sep 5 23:29 /home/tools/
在此目录下创建的文件,其组的所有权自动设置为admins组
[root@bianchengshe ~]# cd /home/tools/ #进入目录
[root@bianchengshe tools]# touch bianchengshe.txt #创建文件
[root@bianchengshe tools]# ls -l #查看文件权限
total 0
-rw-r--r--. 1 root root 0 Sep 5 23:40 bianchengshe.txt
[root@bianchengshe tools]# chmod g+s /home/tools/ #给目录所属组增加S权限
[root@bianchengshe tools]# touch bianchengshe1.txt #创建文件
[root@bianchengshe tools]# ls -l #查看文件权限
total 0
-rw-r--r--. 1 root admins 0 Sep 5 23:42 bianchengshe1.txt
-rw-r--r--. 1 root root 0 Sep 5 23:40 bianchengshe.txt
![图片[1]-Linux如何创建共享目录?-编程社](https://cos.bianchengshe.com/wp-content/uploads/2023/09/image-41.png?imageMogr2/format/webp/interlace/1/quality/100)
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容