Three search commands in linux
There are many commands in linux to view the file path. Here we will summarize them a little.
1. find command
The find command should be the most familiar SEARCH Command and the most powerful search command in linux. It can find any file you want in the specified directory. Usage:
Find <specified directory> <specified condition> <specified action>
If no parameter is added, the current directory and its sub-directories are searched, and no results are filtered, and they are displayed on the screen. Example:
Find.-name test indicates searching for the file named test in the current directory.
Find/home/xiang-amin-2 find the files that have been accessed in the specified directory in the last two minutes
There are many other conditions for specifying the find statement. For more information, see man.
2. The essence of locate is find-name, but the execution efficiency of locate is much faster than that of the find command because its search is not directory-based, instead, search for the database file/var/lib/locatedb. To prevent too many files from being listed, it is generally used with the grep command to find the files in a specific directory. The file is automatically created and updated in linux. To avoid searching for newly created files, run the updatedb command before using it. Locate usage:
Find <File Name>
Example: locate test to find all files starting with test.
3, whereis
This command can only be used for binary files, man files, and source code files.-B indicates binary executable files,-m indicates man files, and-s indicates source files.
Location of all pwd files in whereis pwd
In addition, which and type also have the file search function in some cases. Because it is not very common in practice, it is not described here.