Find files in the system , It is a necessary skill for all engineers ( No matter what you use Windows ,Linux, still MacOS system ). about Linux operating system , Just one
find Command can do a lot of searching .

however , More than one file search command find command , There are still a lot of it . This article is right Linux Send the file search command to conduct a science popularization , So that you can find the documents you need in a short time .

  1. find  

find Command should be the most classic command , When it comes to search tools, the first thing I think about must be find command . however ,find
The command is very powerful , I want to introduce all its functions , I'm afraid I have several articles to write .

therefore , Here's a lazy thief , Introduce the most basic , How to find a file by its name . If we want to search the current directory ( And its subdirectories ) Next all .sh file , You can search like this :

  2. locate  

locate Is another command to search for files based on their names . Different from find command ,locate Command does not need to specify a path , Search directly .

This command is not to search for files directly in every corner of the system , It's called mlocate.db Search under database of . This database is located in
/var/lib/mlocate/mlocate.db , It contains the index of all files in the system , And every morning cron Tools automatically update once .

just because of this ,locate Search speed is much faster than find command , Because it searches directly in the database , Naturally faster .

locate Command after file found , The absolute path of the file will be displayed directly , such as :

however locate There's a drawback to orders , It can't search for files created that day , Because its database is only updated once a day in the morning . Let's say I create a new file now ,locate No way to search :

To solve this problem , We can use updatedb Command to manually update its database :
$ sudo updadb
then , We can search for new files .

  3. which  

which Command is mainly used to find the location of executable files , Its search location is specified at $PATH and $MANPATH Value under environment variable , By default ,which
Command displays the first storage location for the executable :

If an executable is stored in multiple locations , have access to -a Options list all locations .

If you want to find multiple files at once , You can follow me directly which Just after the command .

  4. whereis  

whereis The command will install in the system default directory ( Generally, there are root Software installed by default on permission ) Find binary , Source code , The file in the document that contains the given query keyword .( The default directory is /bin,
/sbin, /usr/bin, /usr/lib, /usr/local/man Etc ).

Generally, it includes the following three parts :

Path to binary

Source path of binary file

corresponding man Path to file

Let's search now ls command :

We can use -b Option to search only the location of the executable , use -B Option to specify search location , use -f Options list file information .

similarly , We can use -s Restrict search to source path only , use -m search man page route , use -s Specify the path to search for source code files , use -M
Specify the path to search for help files .

©2019-2020 Toolsou All rights reserved,
java Four functional interfaces ( a key , simple )os Simple use of module HashMap Explain in detail html Writing about cherry trees , Writing about cherry trees It's unexpected Python Cherry tree (turtle The gorgeous style of Library ) computer network --- Basic concepts of computer network ( agreement , system ) Some East 14 Pay change 16 salary , Sincerity or routine ? Browser kernel ( understand )