locate
locate
is a common Unix tool for quickly finding files by name. It offers speed improvements over the find
tool by searching a pre-constructed database file (stored in /var/lib/mlocate/mlocate.db
), rather than the filesystem directly. The downside of this approach is that changes made since the construction of the database file cannot be detected by locate
. This problem is minimised by regular, typically scheduled use of the updatedb
command, which (as the name suggests) updates the database.
Installation
Although in other distros locate
and updatedb
are in the findutils package, they are no longer present in Arch's package. To use it, install the mlocate package. mlocate is a newer implementation of the tool, but is used in exactly the same way.
Before locate
can be used, the database will need to be created. To do so, simply run updatedb
as root.
Keeping the database up-to-date
You will most likely want to automate the process of regularly updating the database. cron is a common way of doing this (remember when setting up the "cron job" that updatedb must be run by root).