不用find,怎样递归地给目录设置700,给文件设置600权限?
I'm trying to figure out a way to set permissions recursively 700 for dirs and subdirs on a specific path and 600 for files. I would use these commands:
find /path -type d -print0 | xargs -0 chmod 700
find /path -type f -print0 | xargs -0 chmod 600
But the user does not have permission to run the "find" command. As a workaround I tried to make a script that contains the above commands from the root user with setuid sticky bit set so it will run with root privileges (like passwd or sudo commands that normal users run with root privileges):
chmod 4755 script.sh
but i cannot execute the script from the limited user account, it still says that I don't have permission to run the find command.
Does anyone have any idea how i can accomplish this without having to use the "find" command?
Edit: OS: Centos 6.5
Apparently this is very easy to implement. There are 2 ways: using chmod only, or setting ACL (access control list) on the desired path:
Using chmod i would run:
chmod -R u=rwX,g=,o= /path
for the user owner i'm giving capital "X", so it does apply only to directories and not files.
Using ACL:
setfacl -Rm u::rwX,g::0,o::0 /path
setfacl -Rm d:u::rwX,g::0,o::0 /path
again using capital "X" so it applies only to directories and not files. The first command applies the ACL, the second one makes it default policy so newly created files will inherit the desired permissions.
不用find,怎样递归地给目录设置700,给文件设置600权限?的更多相关文章
- Python3:递归实现输出目录下所有的文件
今天来整理一下os库中方法的使用,如何输出一个目录下的所有文件? 1.首先介绍几个基本的的方法: 1)os.getcwd() #返回当前工作目录 2)os.listdir() #返回一个列表, ...
- Linux递归解压缩一个目录下的全部文件
gunzip -r hongchangfirst/data 怎样递归删除那些剩余的非log结尾的文件? 先列出确认一下: find hongchangfirst/data -type f ! -nam ...
- Linux更改目录及其子目录、文件的访问权限
修改某个目录及其下所有文件的权限,要使用-R参数,表示启动递归处理. 例如: #仅将/home/user/test目录的权限设置为rwxr-xr-x /home/user/test #表示将整个/ho ...
- svnkit递归获取指定目录下的全部文件
package demo.wc; import java.util.Collection; import java.util.Iterator; import org.tmatesoft.svn.co ...
- go递归打印指定目录下的所有文件及文件夹
func treedir(fpath string){ // 获取fileinfo if finfo,err := os.Stat(fpath); err == nil { // 判断是不是目录 如果 ...
- java 递归获取一个目录下的所有文件路径
还是日志的问题,log4j生成的日志文件,自动保存到月份所在的文件夹中,需要获取到所有的日志文件,包括文件夹 private List<String> ergodic(File file, ...
- 递归删除指定目录下的 .git 文件
转载自:http://my.oschina.net/armsky/blog/34447 find . -name .git | xargs rm -fr 其中对 xargs 的介绍,可以参照以下内容: ...
- 给定HDFS中某一个目录,输出该目录下的所有文件的读写权限、大小、创建时间、路径等信息,如果该文件是目录,则递归输出该目录下所有文件相关信息。
1 import java.text.SimpleDateFormat; 2 import org.apache.hadoop.fs.*; 3 4 public class E_RecursiveRe ...
- Apache限制某个目录下的PHP文件没有执行权限
为了安全期间,有时我们需要限制网站下的某些目录对于php脚本不能执行. 有两种方法可以参考: 1. 使用.htaccess 文件限制 在要限制php执行的目录下,创建.htaccess文件,加入内容 ...
- wamp中的httpd.conf文件设置
ServerName localhost 缺省情况下,并不需要指定这个ServerName参数,服务器将自动通过名字解析过程来获得自己的名字,但如果服务器的名字解析有问题(通常为反向解析不正确),或者 ...
随机推荐
- MySQL批量数据脚本示例
一.建表 # 新建库 create database bigData; use bigData; #1 建表dept CREATE TABLE dept( id INT UNSIGNED PRIMAR ...
- 【JavaWeb】【JSP】JSP传值到Servlet后端为NULL的问题
JSP传值到Servlet后端为NULL的问题 哔哩哔哩@萌狼蓝天 博客:萌狼工作室-博客园 联系QQ:#3447902411# | 仅限技术交流可添加 | 添加请说明你的方向和来意 1.目标文件路径 ...
- Python用pandas获取Excel数据
import pandas as pd df1 = pd.DataFrame(pd.read_excel(r'C:\python测试文件\我的三国啊.xlsx',sheet_name='Sheet1' ...
- [BUUCTF]PWN——mrctf2020_easyoverflow
mrctf2020_easyoverflow 附件 步骤: 例行检查,64位程序,保护全开 本地试运行的时候就直接一个输入,然后就没了,直接用64位ida打开 只要满足18行的条件,就能够获取shel ...
- [BUUCTF]REVERSE——reverse3
reverse3 附件 步骤: 例行查壳儿,32位程序,无壳儿 32位ida载入,shift+f12检索程序里的字符串,得到了有关flag的提示,而且看到了ABCDE--78这种字符串,猜测存在bas ...
- 添加备注信息(Project)
<Project2016 企业项目管理实践>张会斌 董方好 编著 就在任务信息的[高级]选项卡隔壁,还有一个[备注]选项卡,可别拿备注不当回事,因为任务名称的字数不能太多. 好吧,张同学也 ...
- LuoguB2133 我家的门牌号 题解
Update \(\texttt{2021.11.27}\) 修复了代码中的 \(10000\) 写成 \(n\) 的错误. Content 一个家庭住在一个胡同里面,门牌号从 \(1\) 开始编号. ...
- JAVA获取当前请求的URL地址,包含请求链接中的参数
/** * 获得当前访问的URL路径 * @param request * @return */ public static String getLocation(HttpServletRequest ...
- Android NDK开发篇:Java与原生代码通信(异常处理)
一.捕获异常 异常处理是Java中的功能,在Android中使用SDK进行开发的时候经常要用到.Android原生代码在执行过程中如果遇到错误,需要检测,并抛出异常给Java层.执行原生代码出现了问题 ...
- 【九度OJ】题目1026:又一版 A+B 解题报告
[九度OJ]题目1026:又一版 A+B 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1026 题目描述: 输入两个不超过 ...