chmod+find如何批量授权
发表于:2025-12-01 作者:千家信息网编辑
千家信息网最后更新 2025年12月01日,这篇文章将为大家详细讲解有关chmod+find如何批量授权,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。这两张图是test 这个文件夹下的目录结构图以及权限图。那
千家信息网最后更新 2025年12月01日chmod+find如何批量授权
这篇文章将为大家详细讲解有关chmod+find如何批量授权,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
这两张图是test 这个文件夹下的目录结构图以及权限图。那么接下来我要将test这个目录以及子目录的所有.sh 的文件设置为只有可执行权限要怎么设置呢?执行以下命令后会发现 tesh.sh 和./test1/test1.sh 的权限已经变成---x--x--x 而其它保持不变
find . -name "*.sh" -exec chmod 111 {} \;total 0drwxr-xr-x 2 root root 38 Sep 29 10:31 test1drwxr-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]# lltotal 0d--x--x--x 2 root root 38 Sep 29 10:31 test1d--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]# lltotal 0d--x--x--x 2 root root 38 Sep 29 10:31 test1d--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]# lltotal 0drwxr-xr-x 2 root root 38 Sep 29 10:31 test1drwxr-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如何批量授权"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
文件
权限
目录
只有
命令
篇文章
递归
代表
参数
文件夹
更多
不错
实用
接下来
内容
子目
子目录
就是
差别
引号
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
大学一般有哪些服务器
戴尔服务器大白菜不能启动
护因网络安全课
哪种服务器不能用公网ip
皇冠互联网科技有限公司
金融小程序软件开发
原神用什么语音服务器玩
转行学数据库技术怎么学
网络安全教育法主题团日活动方案
襄樊软件开发培训班
mysql 数据库 建表
重庆梁平众道生鲜软件开发
聚光软件开发
信息系统与数据库计数
校园网网络安全管理制度
平安互联网和平安科技的区别
如何举办网络安全培训班
360网络安全吗
网络安全审计探针
虚拟桌面服务器配置
国家网络安全警示教育片
上海软件开发驻场费用
服务器升级至顶级
大学那个网络安全
襄樊软件开发培训班
海南gps时钟服务器虚拟主机
辽宁软件开发代理商市场
网络安全管理与信息安全
国家网络安全标准包括
如何安装用友数据库