Linux file Lookup--location find command

Source: Internet
Author: User

File Lookup
grep egrep fgrep Text Lookup

File Lookup:
non-real-time, fuzzy matching, lookup is based on the system-wide file database;
# Manually generate file database updatedb;

Real-time search, precision, slow speed
traverse all files in the specified directory to complete the lookup;
support for many search criteria

Find Find Path lookup criteria lookup to future processing operations
Find path: Default to current directory
Lookup criteria: Default to all files under the specified path
processing operation: default to show printing

Matching Criteria:
-name ' filename ': Exact search for file names
file name wildcard:
*: Any character of any length
-iname ' filename ': file name matching is case insensitive
-regex PATTERN: Finding based on regular expressions
-user Usernaem:
-uid UID
-gid GID User is deleted, belong to group GID number
-nouser: Finding files that are not owned by a group
f: Normal file
Combination Conditions
-A and
- O or
-not Non-

-atime + 5-
[+|-]5----------|-----------> NOW

[+|-]# min

MODE based on the right to find accurate
-mode: Each permission must match before the line contains the relationship: The file can only be displayed when the whole country is fully inclusive of MODE
/mode: Nine-bit permissions there's a match.

-print: Display
-ls: Displays the details of each file in the form of a ls-l like class
-ok:commond \; Confirmation is required for each operation
-exec commad \; No confirmation required
Find./-perm-006-exec chmod o-w {} \;
Find./-type D-ok chmod +x {} \;
Find./-perm-020-exec mv {} {}.new \;
Find./-name "*.sh"-a-perm-111-exec chmod o-x {} \;

Find/etc-sixe +1m-exec Echo {} >>/tmp/etc.largefiles \;
Find/etc-size +1m | Xargs Echo >>/tmp/etc.largefiles


1. Find a file with a group of mial that is rooted in the/var directory
Find/var-user Root-group Mail

2. Find files that do not belong to Root,bin or student in the/usr directory
Find/usr-not-user root-a-not-user bin-a-not-user Student
Find/usr-not \ (-user root-o-user bin-o-user student \)

3. Find files that have been modified in the/etc directory for the last week and are not owned by root and student users;
Find/etc-mtime-7-a-not-user root-a-not-user Student

4. Look for files that are not owned or owned by the current system and have been accessed in the most recent day, and change their owner group to root
Find/(\-nouser-o-nogroup \)-a-atime-1-exec chown root:root {} \;

5. Find files larger than 1M in the \etc directory, and write their filenames to the/tmp/etc.largefiles file;
Find/etc-sixe +1m-exec Echo {} >>/tmp/etc.largefiles \;
Find/etc-size +1m | Xargs Echo >>/tmp/etc.largefiles

6. Find files with no write permission for all users in/etc directory, and display their detailed information

Linux file Lookup--location find command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.