hug*_*ige 173 terminal command-prompt chmod
我怎么会使用到644的所有文件和所有文件夹变成755 chmod从linux命令提示符?(终奌站)
hug*_*ige 333
一种方法可能是使用find:
find /desired_location -type d -print0 | xargs -0 chmod 0755
Run Code Online (Sandbox Code Playgroud)
find /desired_location -type f -print0 | xargs -0 chmod 0644
Run Code Online (Sandbox Code Playgroud)
ken*_*orb 99
最简单的方法是:
chmod -R u+rwX,go+rX,go-w /path/to/dir
Run Code Online (Sandbox Code Playgroud)
这基本上意味着:
以ch安格文件mod上课-R给予ecursively:
user:read,write和e Xecute权限,group和other用户:read和e Xecute权限,但不是-write权限.请注意X,除非已经可搜索/可执行,否则将使目录可执行,但不是文件.
+X- 如果任何人已经可以搜索/执行可供所有人搜索/可执行的目录或文件.
请查看man chmod更多详情.
另请参见:如何chmod除文件之外的所有目录(递归)?在SU
Joh*_*sup 26
我能想出的最短的一个是:
chmod -R a=r,u+w,a+X /foo
Run Code Online (Sandbox Code Playgroud)
它适用于GNU/Linux,我相信Posix一般(来自我的阅读:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html).
这样做是:
重要的是,步骤1权限清除所有执行位,因此步骤3仅添加目录(从不文件)的执行位.此外,所有三个步骤都在目录递归之前发生(因此这不等于例如
chmod -R a=r /foo
chmod -R u+w /foo
chmod -R a+X /foo
Run Code Online (Sandbox Code Playgroud)
因为a = r从目录中删除x,所以chmod不能递归到它们中.)
这对我有用:
find /A -type d -exec chmod 0755 {} \;
find /A -type f -exec chmod 0644 {} \;
Run Code Online (Sandbox Code Playgroud)
我最容易记住的是两个操作:
chmod -R 644 dirName
chmod -R +X dirName
Run Code Online (Sandbox Code Playgroud)
+ X仅影响目录.
他们在 https://help.directadmin.com/item.php?id=589上写道:
如果您需要一种快速的方法将目录的public_html数据重置为755,将文件重置为644,则可以使用以下方法:
cd /home/user/domains/domain.com/public_html
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
Run Code Online (Sandbox Code Playgroud)
我进行了测试,并且...有效!
小智 6
在一次通过中同时执行以下操作:
find -type f ... -o -type d ...
Run Code Online (Sandbox Code Playgroud)
在中,找到类型f OR类型d,并执行第一个...用于文件,第二个...用于dirs.特别:
find -type f -exec chmod --changes 644 {} + -o -type d -exec chmod --changes 755 {} +
Run Code Online (Sandbox Code Playgroud)
离开关--changes,如果你希望它默默地工作.