From LQWiki
Jump to: navigation, search

The locate command will return all files and directories that contain the search string in its name. It is basically equivalent to using

find / -name *expression*

Except that it is much faster. It does this by querying the locate database which is updated periodically by the system (usually as a cron job).


$ locate passwd

The locate database can be defined by changing the value of the LOCATE_PATH environment variable. The database is typically updated daily. If you wish to force an update use the updatedb or "locate -u" command.

You can use regular expressions with locate through the -r flag:

locate -r "core\.[0-9]"



(It will also find core.[pid] files, which is handy.)

See also