Linux 寻找不属于某人的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5927489/
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-04 00:51:25  来源:igfitidea点击:

Looking for files NOT owned by someone

linuxfileshellsearch

提问by mike628

I'm looking to recursively look through directories to find files NOT owned by a particular user and I am not sure how to write this.

我希望递归查看目录以查找不属于特定用户的文件,但我不确定如何编写它。

采纳答案by Mel

The find(1) utility has primaries that can be negated ("reversed") using the "!" operator. On the prompt one must however escape the negation with a backslash as it is a shell metacharacter. Result:

find(1) 实用程序具有可以使用“!”否定(“反转”)的原色。操作员。然而,在提示时,必须用反斜杠转义否定,因为它是一个 shell 元字符。结果:

find . \! -user foo -print

回答by Ignacio Vazquez-Abrams

-userfinds by user or user ID, and !inverts the predicate. So, ! -user ....

-user按用户或用户 ID 查找,并!反转谓词。所以,! -user ...

回答by Crayon Violent

You can use this:

你可以使用这个:

find <dir> ! -user <username> 

回答by A.B.

Using z-shell (zsh) you can use

使用 z-shell (zsh) 你可以使用

ls -laR *(^U)

or

或者

ls -la **/*(^U)

to search for all files recursively not owned by you.

递归搜索所有不属于您的文件。

回答by jww

Looking for files NOT owned by someone

寻找不属于某人的文件

Others have answered the question "NOT owned by a particular user"in the body. Here's one that answers the titular question but has not been provided:

其他人在正文中回答了“不属于特定用户”的问题。这是回答名义问题但尚未提供的问题:

$ find / -nouser

You can use it like so:

你可以像这样使用它:

$ sudo find /var/www -nouser -exec chown root:apache {} \;

And a related one:

还有一个相关的:

$ find / -nogroup