Linux 使用 `find -perm` 查找未设置权限的时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4382599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:58:00  来源:igfitidea点击:

Using `find -perm` to find when a permission is not set

linuxbashfind

提问by User1

I want to find the non-readable files in my directory (eg the files with g-r). So I tried this:

我想在我的目录中找到不可读的文件(例如带有 gr 的文件)。所以我试过这个:

find . -perm -g-r

find . -perm -g-r

It shows me all of the files?? So I tried this:

它显示了我所有的文件?所以我试过这个:

find . -perm -g+r

find . -perm -g+r

And it showed me only the readable files. It appears that -perm -g-rmatches all files. I'm using CentOS 5.5. Am I doing something wrong? It doesn't look like -perm -g-rdoes anything useful.

它只向我展示了可读文件。似乎-perm -g-r匹配所有文件。我正在使用 CentOS 5.5。难道我做错了什么?看起来-perm -g-r没什么用。

采纳答案by jgr

Try:

尝试:

find . ! -perm -g+r

find . ! -perm -g+r

回答by Charley

If you want to find files that are non-readable by you, you could use

如果您想查找您无法读取文件,您可以使用

find . ! -readable

回答by seenshee91

You were able to see all files when you executed the below instruction, because you were executing it as root.

当您执行以下指令时,您能够看到所有文件,因为您是以 root 身份执行的。

find . -perm -g-r

Try executing as a normal user.

尝试以普通用户身份执行。