Linux whereis, find the difference between command and locate and application scenarios

Finding a file is in use we use linux in a very commonly used commands.

There are multiple linux command to find files: whereis, find, locate has a similar function to locate, the following will explain the differences between these instructions.

 

  • whereis

Function: locate file directory

whereis command is not positioned to achieve by finding all the files on the disk, you can easily specify an executable file, it is estimated whereis will not find, because the PATH whereis to find files based on environment variables, and PATH is usually set to those paths stored commands, such as / bin, / usr / bin, etc., and therefore the use is limited to whereis position location where the shell command .

  • find

Features: Find files 
find command can be used to start from the specified directory to find the file, it's not as though the speed whereis command, but without any restrictions, and strong function than the whereis command.

  • locate

 Features: Find files or directories 
other than the find command outside, locate commonly used method is to find the file in the system.

The same is not found with the locate command file and find any restrictions, but the execution speed than find a lot faster, the main reason is that, locate not find the file from the disk in real time, but find updatedb command generated by the repository appropriate files and directories, so that speed is of course faster.

 

In Linux, there are quite a good search system. Typically, find not used, because the slow, consumes disk space. Usually, we use whereis or locate to check, if not, find it with a search. why? Since whereis and locate using the database to search data, so very fast, but does not actually search the hard disk, more saving.

Guess you like

Origin www.cnblogs.com/shyroke/p/10938090.html