Linux under File Lookup command find

Source: Internet
Author: User

There are several search file commands under Linux:

Which view the location of the executable file.

Whereis View the location of the file.

Locate to view the file location with the database.

Find actual search hard disk query file name.

Each command has his specific function,

The purpose of the which command is to search for a system in the path specified by the PATH variable.

The location of the command and returns the first search result.

The Whereis command can only be used for program name searches, and only binary files are searched

(parameter-B), man description file (parameter-m), and source code file (parameter-s).

Locate allows users to quickly search the file system for the specified file

Case. The method is to first establish a system including all the file name and path of the data

Library, and then simply query the database when looking for it, without actually going deep into the file system

The system.

The Linux Find command searches the directory structure for files and performs the specified actions.

The Find command under Linux is very important and very powerful, but the content involved is also more, we should be in the practical application of gradually mastered.

The Linux Find command searches the directory structure for files and performs the specified actions.

The Linux Find command provides quite a lot of search criteria and is powerful. Because find has powerful features, it has a lot of options, most of which are worth taking the time to look at. Even if the system contains a network file system (NFS), the Find command works equally well in the file system, and you only have the appropriate permissions. When running a very resource-intensive find command, many people tend to put it in the background because it can take a long time to traverse a large file system (this refers to a file system with more than 30G bytes).

1. Command format:

Find Pathname-options [-print-exec-ok ...]

2. Command function:

Used to locate files in the file tree and make appropriate processing (possibly accessing the disk)

3. Command parameters:

The directory path that the Pathname:find command looks for. For example, use. To represent the current directory, and/to represent the system root directory.

The-print:find command outputs the matched file to standard output.

The-exec:find command for the matching file line This parameter gives the shell life

Make. The form of the corresponding command is ' command ' {} \;, note {} and \;

Space between the.

-OK: It works the same as-exec, except in a more secure mode.

The shell command given by this parameter gives a hint to the user to determine whether to execute before each command is executed.

4. Command options:

-name finds files by file name.

650) this.width=650; "Src=" Http:// -wmp_4-s_4156199441.png "title=" Findname.png "alt=" Wkiol1drgkbzxe7paaamq-ye-yc715.png-wh_50 "/>

-perm to find files according to file permissions.

-prune Use this option to make the Find command not be checked in the currently specified directory

If you use the-depth option at the same time, the-prune will be ignored by the Find command.

-user Search for files according to the owner of the file.

-group finds files according to the group to which the files belong.

-mtime-n +n to find a file according to the time the file was changed-n indicates the text

The change time is less than n days, + n means that the file change time is now n days from

Ago. The Find command also has the-atime and-ctime options, but they are all the same as the-m time option.

-nogroup finds a file that does not have a valid owning group, that is, the group to which the file belongs

does not exist in etc/groups.

-nouser finds a file without a valid owner, that is, the owner of the file does not exist in the/etc/passwd.

-newer file1! File2 look for a file that changes time than the file File1 new but older than the file file2.

-type find a file of a certain type, such as:

B-block device files.


C-character device file.

P-Pipeline file.

L-Symbolic link file.

F-Normal file.

-size N:[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes.

-depth: When looking for a file, first find the file in the current directory, and then look in its subdirectories.

-fstype: Find files located in a type of file system, these file system classes

Type can usually be found in the configuration file/etc/fstab, which contains information about the file system in the system.

-mount: Does not cross the file system mount point when locating files.

-follow: If the find command encounters a symbolic link file, it tracks to the file that the link points to.

-cpio: Use the cpio command for matching files to back up these files to the tape device.

In addition, the following three differences:

-Build time to find files,-n means less than n days, +n refers to n days ago


1. In the/L o G S directory, look for files that change time before 5th and delete them:

650) this.width=650; "Src=" Http:// -wmp_4-s_15343224.png "title=" Find-time.png "alt=" Wkiol1drgikgvo6gaaapm9zsham584.png-wh_50 "/>

2. Linux using the Find command to find File size xx file method

For example: A file of 5556 bytes can be written like this

650) this.width=650; "Src=" Http:// -wmp_4-s_1872443230.png "title=" Find-size.png "alt=" Wkiom1drgtehdjzmaaaolotsaxy694.png-wh_50 "/>

That is, to find files larger than 5555 bytes less than 5557 bytes, the above is the/root directory

There are many more commands to continue to be familiar with in practice.

This article is from the "Qin-wang" blog, make sure to keep this source

Linux under File Lookup command find

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.