开发者

Looking for files NOT owned by a specific user

I'm looking开发者_如何学JAVA to recursively look through directories to find files NOT owned by a particular user and I am not sure how to write this.


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 . \! -user foo -print


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


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


You can use this:

find <dir> ! -user <username> 


Using z-shell (zsh) you can use

ls -laR *(^U)

or

ls -la **/*(^U)

to search for all files recursively not owned by you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜