Find essential applications

Source: Internet
Author: User

Find best application find path-option [-print] [-exec-OK command] {}\;-print outputs the searched files to the standard output-exec command {}\; execute the command operation on the retrieved file. The space between {} And \; is the same as that between-OK and-exec, you only need to consult the user www.2cto.com ================================ =================================- name filename # Find the file named filename-perm # search for-user username Based on the execution permission # search by file owner-nouser # Query files with no valid owner, that is, the file owner does not store-group groupname in/etc/passwd # search for-nogroup by group # Query files without a valid group, that is, the file group does not exist in/etc/groups. -Nouser # Check for files with no valid owner, that is, the file owner does not store-mtime-n in/etc/passwd. # search for files by file change time, -n refers to n days or less, n refers to n days ago-atime-n # searches for files by file access time,-n refers to n days or less, n refers to n days ago-ctime-n # search for files by file creation time,-n refers to n days earlier, and n refers to n days ago-newer f1! F2 # Query files whose change time is earlier than f1 but earlier than f2-type B/d/c/p/l/f # query Block devices, directories, character devices, pipelines, symbolic Link, normal file-size n [c] # Check the file with a length of n [or n Bytes]-depth # search the local directory before entering the subdirectory-fstype # Query files in a certain type of file system, these file system types can usually be found in/etc/fstab-mount # The file query does not span the file system mount point-follow # If you encounter a symbolic link file, use the cpio command for the file-cpio # indicated by the trace link to match the file, back them up to the tape device-prune # ignore a directory ========================== ===========================================$ find ~ -Name "*. txt "-print example: Check the. txt file in home‑home‑and display $ find. -name "[A-Z] *"-print # Query files starting with an uppercase letter $ find/etc-name "host *"-print # Query files starting with a host $ find. -name "[a-z] [a-z] [0--9] [0--9] *. txt "-print # query txt files starting with two lower-case letters and two numbers $ find. -perm 755-print $ find. -perm-007-exec ls-l {}\; # check whether all files that can be read and written by users are the same as-perm 777 $ find. -type d-print $ find .! -Type d-print $ find. -size limit 00c-print # Query files with a length greater than 1 MB $ find. -size 100c-print # Query files with a length of 100c $ find. -size 10-print # Query files with a length of over 10 expired items (1 file = 512 bytes) $ find etc home apps-depth-print | cpio-ivcsc65536-o/dev/rmt0 $ find/etc-name "passwd *"-exec grep "cnscn "{}\; # Check whether the cnscn user $ find logs-type f-mtime 5-exec-OK rm {}\ exists {}\; # In the/logs directory, find the files whose modification time is earlier than 5 days and delete them $ find *. c-exec cp '{}'/tmp ';' # copy the found item to another Place $ find dir-name filename-print | cpio-pdv newdir # If a special file exists, you can use cpio or the syntax $ find. -name "yao *" | xargs file $ find. -name "yao *" | xargs echo "">/tmp/core. log $ find. -name "yao *" | xargs chmod o-w www.2cto.com ====================== ======================================== find-name ap *-o-name may * find/mnt-name tom.txt-ftype vfat file starting with ap or may find/mnt-name t file named tom.txt and vfat file system type under/mnt. Txt! -Find the file "find/tmp-name wa *-type l" with the name tom.txt under "/mnt" and the file system type is not" vfat "under"/tmp "and find the file with the name" wa "and the type as the symbolic link under"/tmp ". find/home-mtime-2 check the file find/home-atime-1 that has been modified in the last two days under/home to find/home- check the find/home-amin 30 files modified 60 minutes ago in the/home Directory of mmin 60 and find/home-amin 30 files that have been accessed in the last 30 minutes. find/home-newer tmp.txt files whose Update Time is closer than tmp.txt files under/home. find/home-anewer tmp.txt file or directory. find/home-used-2 files or directories that are last to tmp.txt in/home, files or objects that have been accessed within 2 days Find/home-user cnscn list/home directory find/home-uid 501 list/home directory where the user's identification code is greater than 501 /home-group cnscn list/home the files or directories in the group whose group is cnscn find/home-gid 501 list/home the files or directories where the group id is 501 find/home-nouser list files or directories not belonging to local users in/home are listed in find/home-nogroup. files or directories not belonging to local groups in/home are listed in find/home-name tmp.txt-maxdepth 4/tmp.txt in home. the maximum depth of the query is 3 layers of find/home-name tmp.txt-mindepth 3. From Layer 3, check find/home-empty to find files with a size of 0 or empty directories. Find/home-size 512 k search for files larger than 512 k find/home-size-k search for files smaller than k find/home-links 2 check files or directories with hard connections greater than 2 find/home-perm 0700 find a file or directory with the permission of 700. -type f-exec ls-l {}\; find all common files find/tmp-name tmp.txt-exec cat {}\; find/tmp-name tmp.txt-OK rm {}\; ========================================================== ================== find/-amin-10 # find the file accessed in the last 10 minutes in the system find/-atime-2 # find in find/-empty # find the file accessed in the last 48 hours in the system Empty file or folder find/-group cat # find the groupcat file in the system find/-mmin-5 # find the file modified in the last 5 minutes in the system find/ -mtime-1 # find the file modified in the last 24 hours in the system find/-nouser # find the file belonging to the void user in the system find/-user fred # search in the system the files belonging to the user FRED show all current disk areas: df-k | awk '{print $1}' | grep-v 'none' | sed s "// \/dev \ // g" sda2sda1 find the specified file, and clear it: find ~ /Bin-type f-iname SERVERLIST | xargs-I {} cp/dev/null {} the difference between the following two commands: find bin/-name check *-mtime 3-exec ls {}\; find bin/-name check *-mtime 3 | in xargs ls, if the target file is not found in find, the ls parameter is blank, all the problems in the current directory are listed. deletion is risky, while exec does not;

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.