Find is the most powerful, but retrieve the hard disk, relatively slow;
Whereis can only check binary files, documentation, source files, etc.;
Locate can check all documents, but the same as the Whereis is the contents of the database, fast, but there is delay;
which can only look for executable files and find them in the path variable.
Asher in the use of instructions to operate Ubuntu, often need to know the path of the file, so, also often used to search for file instructions, the more commonly used is whereis and find, in fact, there are locate and which two instructions available, these four commands have different functions, Asher has been time to figure out, today took a bit of time, it is organized as follows.
Find this is the most powerful command, you can use the file name, owner, group and permissions ... Wait a bunch to search for files, however, the Find command is certain to specify the path of the search, otherwise only search the current folder, for example, Asher home directory with the find hosts command to search the hosts file, you must not find things, if you use FIND/ETC hosts, There will be a bunch of files in the name of the hosts this four-word all files out, if you change to sudo find/etc-name hosts will find more close to the list of files we are looking for.
Locate this directive differs from the other three directives in that the locate directive is not an appropriate way to search for files, but rather to search the database created and updated by the updatedb instruction and read into the memory, so the locate command is much faster than the other instructions, so When the Asher executes the locate hosts directive, it is almost immediately listed in the file name with the hosts this four-word file out of all the files! However, the usual advantages are from weaknesses, as long as they are installed, before the updatedb is executed, These new files are not found with the locate directive.
Whereis This command will only search for a few specific paths, such as/usr,/bin or etc, suitable for use in the search for Ubuntu executable files and original files and man instructions, if you use Whereis host to search the host file, you can find the desired results, If the file used to search the home directory, it will not be found.
Which this command search scope than the previous Whereis smaller, which instructions only used to search Ubuntu/linux instruction program, if, Asher with which hosts command to find the hosts, I'm sorry Oh! must not be found, Because the hosts are not instructions, then if the house changed to which which or which php5, then there will be a result run out, because which and php5 are instruction miles!
This sort down, asher the conclusion is, want to use locate quickly, to be sure to use Find, to check the system file with Whereis, to check instructions with which, afraid of trouble, as long as a good learning to find instructions can be.
The differences between the four find command Find,locate,whereis,which