Easy Tutorial
❮ Linux Comm E2Fsck Linux Comm Edquota ❯

Linux locate Command

Linux Command Manual

The Linux locate command is used to find documents that match specified conditions. It searches within a database that stores document and directory names to locate files or directories that match the pattern.

Typically, you only need to enter locate yourfilename to search for a specific file.

Syntax

locate [-d ][--help][--version][pattern...]

Parameters:

Examples

To find the passwd file, enter the following command:

locate passwd

To search for all files in the etc directory that start with sh:

locate /etc/sh

To ignore case and search for all files in the current user's directory that start with r:

locate -i ~/r

Additional Notes

Unlike find, locate does not search the hard drive; it only searches within the /var/lib/slocate database.

locate is faster than find because it does not perform real-time searches but relies on a database. The file database is typically located at /var/lib/slocate/slocate.db, and locate searches are based on this database's updates, which are usually maintained by the system. You can also manually update the database with the command:

updatedb

By default, updatedb runs once a day.

Linux Command Manual

❮ Linux Comm E2Fsck Linux Comm Edquota ❯