find vs locate in Ubuntu

Published: May 16, 2022

find vs locate in Ubuntu

In this article, we would cover the difference between find and locate command-line utilities in Ubuntu. We have already discussed these two in previous articles. To know about find and locate -

  1. find files with locate in Ubuntu,
  2. Search files in Ubuntu using find command.

Both of these commands are mainly used to find location of files. As we were writing the above two articles, we thought of few differences which separate the two. And, this would enable a user to make an informed decision. Both of these commands have got their share of pros and cons. We try to cover as much as we can next.

find vs locate in Ubuntu

I. find mainly searches the directory tree to search files whereas locate looks for files in a database.

II. Since, locate searches a database therefore, it is much faster than find command.

III. find command would show us the results in real-time. As, it searches the directory tree, therefore any new additions/deletions would be picked up by find command. Whereas, locate command uses a database and any new additions/deletions would only show up after the database gets updated.

IV. /etc/updatedb.conf configuration file limits the files which can be a part of the database. Not all the files would be searched while using located. But, in case of find - it searches for all the files in a system.

V. Lastly, find command has got numerous options available to use with it - a user, therefore, can search according to his/her requirements.

Furthermore, though its not a part of the article. But, still we would like to share. The database for locate command is stored at -

/var/lib/plocate/plocate.db

In conclusion, choose the utility which makes your outcome efficient. Both these command-line utilities are capable to handle variety of conditions. Only the user knows what would work for him/her the best.