There are several search file commands under Linux: Find, Whereis, which, and locate.
Which: View the location of the executable file
Whereis: Viewing the location of a file
Locate: Viewing files with a database
Find: Actual search drive Query
Where find is the most commonly used and most powerful find command. It can be found in real-time, accurate search, but slow. The following is a detailed description of the find instruction related usage.
Find command:
"Format" Find [specify Find directory] [find rule] [action executed after find]
The default path is the current directory; The default expression is-print
1. Specify the search directory
650) this.width=650; "title=" Which.png "alt=" Wkiol1der0faq7csaaahmwdqssm474.png "src=" http://s3.51cto.com/wyfs02/ M00/80/e7/wkiol1der0faq7csaaahmwdqssm474.png "/>
2. Search by file name
-name: Search by file name (exact lookup)
-iname: Search by file name, but not case sensitive
650) this.width=650; "title=" Which.png "alt=" Wkiom1deqluqstyuaaaemgg9dpg693.png "src=" http://s2.51cto.com/wyfs02/ M02/80/e9/wkiom1deqluqstyuaaaemgg9dpg693.png "/>
Also introduce the file name of the knowledge of the wildcard.
1)* indicates A wildcard of any character
650) this.width=650; "title=" Which.png "alt=" Wkiom1depipq6_blaaafjbro60s324.png "src=" http://s1.51cto.com/wyfs02/ M00/80/e8/wkiom1depipq6_blaaafjbro60s324.png "/>
2)? Indicates the wildcard of any single character
650) this.width=650; "title=" Which.png "alt=" Wkiol1dep2cyyrteaaaafgld57i385.png "src=" http://s4.51cto.com/wyfs02/ M01/80/e7/wkiol1dep2cyyrteaaaafgld57i385.png "/>
3) [] means any character inside the wildcard brackets
650) this.width=650; "title=" Which.png "alt=" Wkiom1depzqa4is-aaawbdwm_2y048.png "src=" http://s1.51cto.com/wyfs02/ M00/80/e9/wkiom1depzqa4is-aaawbdwm_2y048.png "/>
3. Regular Expression Lookup
! : Non-conditional;
- A: With conditions (-and);
- o: Or condition (-or), connect two different conditions (two conditions to satisfy one)
-not non-conditional (with "! "Same, reverse the conditions")
650) this.width=650; "title=" Which.png "alt=" Wkiol1detgybwxygaaa-ybzgvhu458.png "src=" http://s1.51cto.com/wyfs02/ M01/80/e8/wkiol1detgybwxygaaa-ybzgvhu458.png "/>
4, according to file type to find files
"-type"
F: ordinary documents; D: catalog files; L: linked files; B: block device files; C: character device files; P: pipeline files; S:socket file
650) this.width=650; "title=" Which.png "alt=" Wkiol1dercas6st6aabwldnzzgw652.png "src=" http://s1.51cto.com/wyfs02/ M01/80/e7/wkiol1dercas6st6aabwldnzzgw652.png "/>
5. Find files based on file size
"-size"
-size N: Find files with file lengths equal to N;-size-n: Find files with file lengths less than n ;-size +n: Find files with file lengths greater than N
650) this.width=650; "title=" Which.png "alt=" Wkiol1deuzrhiaqhaaa4_m6ipgw476.png "src=" http://s4.51cto.com/wyfs02/ M00/80/e8/wkiol1deuzrhiaqhaaa4_m6ipgw476.png "/>
6. Find files based on file time
-atime: access Time , the last time the user visited the file;
-mtime: modified time, the last time the file content was modified.
-ctime: Change time , file metadata (metadata, such as permissions or ownership) the last time it was changed.
650) this.width=650; "title=" Which.png "alt=" Wkiol1dewgxdhvg6aabbk0zljxi837.png "src=" http://s5.51cto.com/wyfs02/ M00/80/e8/wkiol1dewgxdhvg6aabbk0zljxi837.png "/>
7. Find files based on file permissions
"-prem"
Permission symbols: Rex is readable, writable, and executable, respectively. When the permission symbol is-e-: Indicates that it can only be written, octal is represented as 2, followed by the representation.
650) this.width=650; "title=" Which.png "src=" http://s1.51cto.com/wyfs02/M00/80/EB/ Wkiom1dexauisjtuaabjwkv25iu722.png "alt=" Wkiom1dexauisjtuaabjwkv25iu722.png "/>
8. Find files based on the users and groups they belong to
-user: Find files according to owner
-group: Finding files According to the genus Group
650) this.width=650; "title=" Which.png "src=" http://s1.51cto.com/wyfs02/M02/80/E9/ Wkiol1dezm-tjghkaaa0yu7n5tu225.png "alt=" Wkiol1dezm-tjghkaaa0yu7n5tu225.png "/>
which directive:
The purpose of the which command is to search for the location of a system command in the path specified by the path variable, and return the first search result. That is, with the which command, you can see whether a system command exists, and the command that executes exactly which location.
"Format" which executable file name
-N: Specifies the length of the file name, and the specified length must be greater than or equal to the longest file name in all files.
-P: The same as the-n parameter, but the path to the file is included here.
-W: Specifies the width of the field at the output.
-V: Display version information
650) this.width=650; "title=" Which.png "alt=" Wkiol1dejj3tfhdzaaa4vwxhmpy803.png "src=" http://s5.51cto.com/wyfs02/ M01/80/dd/wkiol1dejj3tfhdzaaa4vwxhmpy803.png "/>
which is based on the directory within the path variable configured by the user to search for a running file, so the commands found by the different path configuration contents are not the same. The CD is a bash built-in command, but the which default is to find the directory within the PATH, so it cannot be found. When looking for which there will be two which, one of which is alias, which is called the "command alias", meaning that the input which is equivalent to the sequence of commands followed.
Whereis directive:
The Whereis command can only be used for program name searches. And only the binaries (parameter-B), the man description file (parameter-m), and the source code file (parameter-s) are searched. If the argument is omitted, all information is returned.
The Whereis command locates the location of the executable file, the source code file, and the Help file in the file system. The properties of these files should belong to the original code, binary files, or Help files. The Whereis program also has the ability to search for source code, specify alternate search paths, and search for unusual items.
"Format" Whereis file name
-B: Locate the executable file.
-M: Locate the Help file.
-S: Locate the source code file.
-U: Searches the default path for files other than executables, source code files, and Help files.
650) this.width=650; "title=" Which.png "alt=" Wkiom1dekkat_wv7aabnars8mla450.png "src=" http://s5.51cto.com/wyfs02/ M01/80/df/wkiom1dekkat_wv7aabnars8mla450.png "/>
The Whereis lookup is very fast compared to find, because the Linux system records all the files in the system in a database file, and when you use Whereis and locate, you look for data from the database instead of traversing the hard disk like the Find command to find and high efficiency .
However, the database files are not updated in real time , and are updated once a week by default, so when you look up files with Whereis and locate, you sometimes find data that has been deleted, or if you just created the file but can't find it because the database file is not updated.
Locate directive:
Locate effect: Users can quickly search the file system for the specified file. The method is to create an index database that includes all the file names and paths within the system, and then simply query the index database when looking for it without actually going into the file system.
"Format" Locate file name
Eg:locate passwd (as long as the passwd included will be displayed)
650) this.width=650; "title=" Which.png "alt=" Wkiom1dem8oaohcxaabadgz8zrg439.png "src=" http://s4.51cto.com/wyfs02/ M02/80/e8/wkiom1dem8oaohcxaabadgz8zrg439.png "/>
Locate can be filtered
-I: Case-insensitive when locating files
-N: Show only the first n rows of the search results
650) this.width=650; "title=" Which.png "alt=" Wkiol1denbpcsa8yaabuyick-bq334.png "src=" http://s3.51cto.com/wyfs02/ M00/80/e6/wkiol1denbpcsa8yaabuyick-bq334.png "/>
650) this.width=650; "title=" Which.png "alt=" Wkiol1den8xxhoy_aabauhwuoas113.png "src=" http://s2.51cto.com/wyfs02/ M02/80/e7/wkiol1den8xxhoy_aabauhwuoas113.png "/>
650) this.width=650; "title=" Which.png "alt=" Wkiom1den0xy_kq8aaaos8f8oge542.png "src=" http://s2.51cto.com/wyfs02/ M02/80/e8/wkiom1den0xy_kq8aaaos8f8oge542.png "/>
This article is from the "Scen" blog, make sure to keep this source http://10741357.blog.51cto.com/10731357/1782662
"Linux" File lookup: Find