Locate
Jump to navigation
Jump to 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).
Example:
$ locate passwd /etc/init.d/rpasswdd /etc/pam.d/passwd /etc/pam.d/rpasswd /etc/passwd /etc/passwd.old /etc/samba/smbpasswd
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]"
returns:
/usr/share/man/man4/pcmcia_core.4.gz /usr/share/man/man2/mincore.2.gz
(It will also find core.[pid] files, which is handy.)