不用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参数,服务器将自动通过名字解析过程来获得自己的名字,但如果服务器的名字解析有问题(通常为反向解析不正确),或者 ...
随机推荐
- linux基础-TCP/IP协议篇
一.网络TCP/IP层次模型 1.网络层次模型概念介绍:TCP/IP协议就是用于简化OSI层次,以及相关的标准.传输控制协议(tcp/ip)族是相关国防部(DoD)所创建的,主要用来确保数据的完整性及 ...
- java 整型
byte(1字节).short(2字节).int(4字节).long(16字节) java中前缀加上0b或者0B就可以写二进制数,前缀加上0就可以写八进制数,前缀加上0x或者0X就可以写十六进制数 一 ...
- 热部署详细步骤---·> 小热身!
IDEA 2018.1.5 4版本 热部署 网址:https://www.jb51.net/softjc/629271.html
- IO中同步异步,阻塞与非阻塞 -- 通俗篇
一.同步与异步 同步/异步, 它们是消息的通知机制 1. 概念解释 A. 同步 所谓同步,就是在发出一个功能调用时,在没有得到结果之前,该调用就不返回. 按照这个定义,其实绝大多数函数都是同步调用(例 ...
- [BUUCTF]REVERSE——内涵的软件
内涵的软件 附件 例行检查,32位程序 32位ida载入,shift+f12检索程序里的字符串 看到一个很像flag的字符串,拿去尝试一下,成功 flag{49d3c93df25caad8123213 ...
- React-Router(一)
React-Router基础知识 import React from "react"; import { BrowserRouter as Router, Switch, Rout ...
- JAVA把InputStream 转 字节数组(byte[])
import org.apache.commons.io.IOUtils; byte[] bytes = IOUtils.toByteArray(inputStream); 如果没有这个包 就加下依赖 ...
- C/C++ byte 转 int 有符号数,转成Int 无符号数
p.p1 { margin: 0; font: 12px "Helvetica Neue"; color: rgba(69, 69, 69, 1); min-height: 14p ...
- 【LeetCode】404. Sum of Left Leaves 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目大意 题目大意 解题方法 递归 迭代 日期 [LeetCode] 题目地址:h ...
- Code(hdu5212)
Code Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...