Chmod递归地 [英] Chmod recursively

查看:151
本文介绍了Chmod递归地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存档,由其他人存档,我想在下载它之后自动更改提取的文件内的文件系统的分支以获得读取权限。 (我不能改变如何创建存档)。

我已经看了这个线程: chmod:如何以递归方式将执行权限添加到已具有执行权限的文件中进入一些其他的,但没有喜悦。

这些目录原来带有多个但错误的标志,它们可能会显示为:

  drwx ------ 
d --- rx ---
drwxrwxr-x
dr - r-xr- -

这些只是我迄今为止发现的少数,但可能更多。



找到错误,当尝试查看没有 x 权限,所以不会将它传递给 chmod 。到目前为止,我一直在做的是手动更改父目录的权限,然后进入子目录并为他们执行相同的操作。但是这是很多手工劳动。有没有办法自动做到这一点?



I。我现在怎么做:

$ p
$ b $ $ $ $ $ $ $ -R + x
$ chmod -R + r

直到我没有错误,

  $ find -type f -exec chmod -x {} + 

但是必须有更好的办法。

除了执行访问之外,还需要读取访问权限以列出目录。如果你只有执行权限,那么你可以找到目录中的条目名称,但没有其他的信息(甚至没有类型,所以你不知道哪个是子目录)。这适用于我:

  find。 -type d -exec chmod + rx {} \; 


I have an archive, which is archived by someone else, and I want to automatically, after I download it, to change a branch of the file system within the extracted files to gain read access. (I can't change how archive is created).

I've looked into this thread: chmod: How to recursively add execute permissions only to files which already have execute permission as into some others, but no joy.

The directories originally come with multiple but all wrong flags, they may appear as:

drwx------
d---r-x---
drwxrwxr-x
dr--r-xr--

Those are just the few I've discovered so far, but could be more.

find errors when tries to look into a directory with no x permission, and so doesn't pass it to chmod. What I've been doing so far, is manually change permissions on the parent directory, then go into the child directories and do the same for them and so on. But this is a lot of hand labour. Isn't there some way to do this automatically?

I.e. how I am doing it now:

do:

$ chmod -R +x
$ chmod -R +r

until I get no errors, then

$ find -type f -exec chmod -x {} +

But there must be a better way.

解决方案

You need read access, in addition to execute access, to list a directory. If you only have execute access, then you can find out the names of entries in the directory, but no other information (not even types, so you don't know which of the entries are subdirectories). This works for me:

find . -type d -exec chmod +rx {} \;

这篇关于Chmod递归地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆