https://stackoverflow.com/questions/36553701/how-to-set-permissions-recursively-700-for-folders-and-600-for-files-without-u

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权限?的更多相关文章

  1. Python3:递归实现输出目录下所有的文件

    今天来整理一下os库中方法的使用,如何输出一个目录下的所有文件? 1.首先介绍几个基本的的方法: 1)os.getcwd()  #返回当前工作目录 2)os.listdir()    #返回一个列表, ...

  2. Linux递归解压缩一个目录下的全部文件

    gunzip -r hongchangfirst/data 怎样递归删除那些剩余的非log结尾的文件? 先列出确认一下: find hongchangfirst/data -type f ! -nam ...

  3. Linux更改目录及其子目录、文件的访问权限

    修改某个目录及其下所有文件的权限,要使用-R参数,表示启动递归处理. 例如: #仅将/home/user/test目录的权限设置为rwxr-xr-x /home/user/test #表示将整个/ho ...

  4. svnkit递归获取指定目录下的全部文件

    package demo.wc; import java.util.Collection; import java.util.Iterator; import org.tmatesoft.svn.co ...

  5. go递归打印指定目录下的所有文件及文件夹

    func treedir(fpath string){ // 获取fileinfo if finfo,err := os.Stat(fpath); err == nil { // 判断是不是目录 如果 ...

  6. java 递归获取一个目录下的所有文件路径

    还是日志的问题,log4j生成的日志文件,自动保存到月份所在的文件夹中,需要获取到所有的日志文件,包括文件夹 private List<String> ergodic(File file, ...

  7. 递归删除指定目录下的 .git 文件

    转载自:http://my.oschina.net/armsky/blog/34447 find . -name .git | xargs rm -fr 其中对 xargs 的介绍,可以参照以下内容: ...

  8. 给定HDFS中某一个目录,输出该目录下的所有文件的读写权限、大小、创建时间、路径等信息,如果该文件是目录,则递归输出该目录下所有文件相关信息。

    1 import java.text.SimpleDateFormat; 2 import org.apache.hadoop.fs.*; 3 4 public class E_RecursiveRe ...

  9. Apache限制某个目录下的PHP文件没有执行权限

    为了安全期间,有时我们需要限制网站下的某些目录对于php脚本不能执行. 有两种方法可以参考: 1.  使用.htaccess 文件限制 在要限制php执行的目录下,创建.htaccess文件,加入内容 ...

  10. wamp中的httpd.conf文件设置

    ServerName localhost 缺省情况下,并不需要指定这个ServerName参数,服务器将自动通过名字解析过程来获得自己的名字,但如果服务器的名字解析有问题(通常为反向解析不正确),或者 ...

随机推荐

  1. Apifox(2)快速上手apifox

    快速上手 使用场景 Apifox 是接口管理.开发.测试全流程集成工具,使用受众为整个研发技术团队,主要使用者为前端开发.后端开发和测试人员. 前端开发 接口文档管理 接口数据 Mock 接口调试 前 ...

  2. centos源码安装ruby

    目录 一.简介 二.程序部署 一.简介 Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言.rvm是ruby的管理器,可以切换ruby版本,下载ruby. 二.程序部署 1.下载ruby w ...

  3. Tableau如何绘制双柱折线组合图

    一.数据准备如下所示 二.将日期拖拽至列,销售额拖拽至行,结果如下所示 三.右键日期排序-选择手动排序 四.将指标拖拽至标记卡上 五.创建计算字段增长率 SUM(IF YEAR(日期)=2017 th ...

  4. 数据类型Table.TransformColumnTypes(Power Query 之 M 语言)

    数据源: 任意数据源 目标: 设置适合的数据类型 操作过程: 选取指定列>[主页]>[数据类型]>选取 选取指定列>[转换]>[数据类型]>选取 选取指定列> ...

  5. MySQL 定时器

    mysql定时器是系统给提供了event,而oracle里面的定时器是系统给提供的job.废话少说,下面创建表:create table mytable (id int auto_increment ...

  6. 在react项目中使用require引入图片不生效

    如果使用create-react-app和require导入图像,require返回一个ES模块而不是字符串.这是因为在file-loader中,esModule选项是默认启用的. 用以下方式之一导入 ...

  7. 什么是SEO配置

    SEO是什么 搜索引擎优化,又称为SEO,即Search Engine Optimization,它是一种通过分析搜索引擎的排名规律,了解各种搜索引擎怎样进行搜索.怎样抓取互联网页面.怎样确定特定关键 ...

  8. DKT模型及其TensorFlow实现(Deep knowledge tracing with Tensorflow)

    今年2月15日,谷歌举办了首届TensorFlow Dev Summit,并且发布了TensorFlow 1.0 正式版. 3月18号,上海的谷歌开发者社区(GDG)组织了针对峰会的专场回顾活动.本文 ...

  9. qt creator设置默认输出目录

    note creator version : 4.13.1 敲黑板,一定要先配置好 Qt creator的default build directory , 再创建项目,最后再编译 敲黑板,一定要先配 ...

  10. 1120 机器人走方格 V3

    1120 机器人走方格 V3 基准时间限制:1 秒 空间限制:131072 KB N * N的方格,从左上到右下画一条线.一个机器人从左上走到右下,只能向右或向下走.并要求只能在这条线的上面或下面走, ...