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.

最新文章

  1. u3d_Shader_effects笔记5 第二章 通过UV,进行纹理移动
  2. Matlab中fsolve传递系数变量
  3. php null o false ''
  4. JQuery函数库
  5. android性能小贴士 翻译
  6. Cache 工具类
  7. JPEG 图
  8. Python基础知识--列表和集合
  9. Kafka安装部署
  10. jQuery中live函数的替代-【jQuery】
  11. windows openssh server 安装试用
  12. 【图文详细教程】maven3安装配置+eclipse离线安装maven3插件《《唯一成功的教程~~~2018-01-09》》
  13. OpenCV-Python基本功能
  14. arcgis_SDE安装步骤
  15. iOS: 动态更改 backBarButtonItem 的 title
  16. Java eclipse Myeclipse tomcat安装及配置
  17. ref和out的使用与区别【转】
  18. tortoiseGit 如何github提交代码
  19. jq_常用方法
  20. java web 资源文件读取

热门文章

  1. 搭建mybatis开发环境
  2. 利用代码覆盖率提高嵌入式软件的可靠性 - VectorCAST
  3. Mybatis-plus报Invalid bound statement (not found)错误
  4. ios获取文件MD5值
  5. 显示摘要任务(Project)
  6. CF816A Karen and Morning 题解
  7. LuoguP7375 [COCI2018-2019#5] Jarvis 题解
  8. Docker从入门到精通(八)——Docker Compose
  9. java 图形化小工具Abstract Window Toolit
  10. Tornado.web.Application之-settings