网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

chmod+find如何批量授权

这篇文章将为大家详细讲解有关chmod+find如何批量授权,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及航空箱等,在成都网站建设成都全网营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

这两张图是test 这个文件夹下的目录结构图以及权限图。那么接下来我要将test这个目录以及子目录的所有.sh 的文件设置为只有可执行权限要怎么设置呢?执行以下命令后会发现 tesh.sh 和./test1/test1.sh 的权限已经变成---x--x--x 而其它保持不变

find . -name "*.sh" -exec chmod 111 {} \;
total 0
drwxr-xr-x 2 root root 38 Sep 29 10:31 test1
drwxr-xr-x 2 root root  6 Sep 29 10:13 test2
-rw-r--r-- 1 root root  0 Sep 29 10:38 test.bash
---x--x--x 1 root root  0 Sep 29 10:22 test.sh
-rw-r--r-- 1 root root  0 Sep 29 10:38 test.tx

find .  -name "*.sh"  与 find . -name *.sh 的区别是少了个双引号,结果就是一个递归,一个不递归。

有人会说了 chmod 有个 -R 参数就可以实现递归了。 但是chmod -R 实现的是无差别攻击所以并不适用,以上授权命令还可以写成这样。效果上是一样的。

把 文件里面.txt 改成执行权限

[root@oracle1 test]# chmod 111 `find . -name "*.txt"`
[root@oracle1 test]# ll
total 0
d--x--x--x 2 root root 38 Sep 29 10:31 test1
d--x--x--x 2 root root  6 Sep 29 10:13 test2
-rw-r--r-- 1 root root  0 Sep 29 10:38 test.bash
---x--x--x 1 root root  0 Sep 29 10:22 test.sh
---x--x--x 1 root root  0 Sep 29 10:38 test.txt

那么问题又来了 我一个目录下要是只有文件与文件夹的区别呢?  好的 ,这个时候你就可以用 find  命令的 -type 参数了 type 后面 d代表目录,f 代表 文件

给文件设置为只有可执行权限

[root@oracle1 test]# chmod 111 `find . -type f`
[root@oracle1 test]# ll
total 0
d--x--x--x 2 root root 38 Sep 29 10:31 test1
d--x--x--x 2 root root  6 Sep 29 10:13 test2
---x--x--x 1 root root  0 Sep 29 10:38 test.bash
---x--x--x 1 root root  0 Sep 29 10:22 test.sh
---x--x--x 1 root root  0 Sep 29 10:38 test.txt

给目录设置为755权限

[root@oracle1 test]# chmod 755 `find . -type d`
[root@oracle1 test]# ll
total 0
drwxr-xr-x 2 root root 38 Sep 29 10:31 test1
drwxr-xr-x 2 root root  6 Sep 29 10:13 test2
---x--x--x 1 root root  0 Sep 29 10:38 test.bash
---x--x--x 1 root root  0 Sep 29 10:22 test.sh
---x--x--x 1 root root  0 Sep 29 10:38 test.txt

关于“chmod+find如何批量授权”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


当前名称:chmod+find如何批量授权
标题链接:http://bjjierui.cn/article/jjeois.html

其他资讯