File search commands in Linux

Source: Internet
Author: User

Five Linux file search commands: find, locate, whereis, which, type

Find: find the path of the file or directory

  1. Format: find [path] [expression]
  2. Expression:
  3. -Name: Find the file named filename
  4. -Perm: search by execution permission
  5. -Empty: searches for empty files or directories.
  6. -User: search by file owner
  7. -Group: search by group
  8. -Nogroup: Check for files without a valid group. That is, the file group does not exist in/etc/groups.
  9. -Nouser: Check for files with no valid owner, that is, the file owner is not stored in/etc/passwd.
  10. -Mtime: searches for files based on the file change time.
  11. -Atime: searches for files by file access time
  12. -Ctime: searches for files based on the file creation time.
  13. -Newer: query the files or directories updated at the change time.
  14. -Type: Check for block Device B, Directory d, character Device c, pipeline p, symbolic link l, common file f
  15. -Size n [c]: searches for files with the size of n blocks (512 bytes) [or n Bytes]
  16. -Inum: search by I Node
  17. -Depth: enable the local directory to be searched before entering the subdirectory.
  18. -Fstype: Query files in a certain type of file system. These file system types can be found in/etc/fstab.
  19. -Mount: The file query does not span the mount point of the file system.
  20. -Cpio: Use the cpio command to back up matching files to tape devices.
  21. -Prune: ignore a directory
  22. -Maxdepth: the depth of the queried directory
  23. -Exec: find the file and execute the following command find...-exec CMD {}\;
  24. -OK: ask if you want to execute the following command find...-OK CMD {}\;
-Perm mode indicates a strict match.-perm-mode indicates that 1 in the transition mode to binary must all match (no matter 0 bits) -perm + mode indicates that the value 1 required for switching mode to binary must be partially matched (no matter 0 bits)-ctime/atime/mtime/cmin/amin/mmin: searches by time in days: ctime, atime, and mtime are measured in minutes: cmin, amin, and mminc -- change indicate that the object property has been modified. a -- accessm -- modify indicates that the object content has been modified. + n indicates that the object content is changed before n days.-n indicates that the object content is less than n days.
  1. [Root @ rhel6 ~] # Find/etc/-name "host *" "Query files or directories starting with host in the/etc/directory (including subdirectories"
  2. [Root @ rhel6 ~] # Find-type l "Query files in the current directory whose file type is link"
  3. [Root @ rhel6 ~] # Find-size + 0000000c "querying files larger than 10 MB in the current directory"
  4. [Root @ rhel6 ~] # Find-size-1 K "querying <1 K files in the current directory"
  5. [Root @ rhel6 ~] # Find/etc-name inittab-o-size + 17 M "Query files with names inittab or files> 17M in the/etc/directory"
  6. [Root @ rhel6 ~] # Find/etc-name "*. conf" [-a]-size + 20 k "Query files whose names are *. conf and whose names are <20 k in the/etc/directory"
  7. [Root @ rhel6 ~] # Find/etc/*-name "*. conf"-not-name "* http *" Query files whose names are *. conf but do not contain http in the/etc directory"
  8. [Root @ rhel6 ~] # Find/etc/-empty "query empty files or empty directories in the/etc/directory"
  9. [Root @ rhel6 ~] # Find/var-user Oracle "query the files or directories in the/var/directory that belong to the user's oracle"
  10. [Root @ rhel6 ~] # Find/home-group xfcy
  11. [Root @ rhel6 ~] # Find-inum 1024 "query the files or directories with an I node of 1024 in the current directory"
  12. [Root @ rhel6 ~] # Find-newer new "query new files or directories in the current directory than new files"
  13. [Root @ rhel6 ~] # Find/etc/-nouser-o-nogroup "Query files or directories (dangerous files) that do not belong to local users in the/etc/directory )"
  14. [Root @ rhel6 ~] # Find/data/-mmin-10 "Query files whose content has been modified within 10 minutes in the/data/directory"
  15. [Root @ rhel6 ~] # Find/proc/-type f-maxdepth 1 "Query files of the common file type in the/data/directory without querying subdirectories"
  16. [Root @ rhel6 ~] # Find/data/-mtime-10-exec rm {}\; "query and delete the modified files in the/data/directory within 10 minutes"
  17. [Root @ rhel6 ~] # Find/data/-mtime-10-OK rm {}\; "query the files whose content has been modified within 10 minutes in the/data/directory and ask whether to delete the files (y/n )"
  • 1
  • 2
  • Next Page

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: info-contact@alibabacloud.com 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.