Linuxlab

locate command in Linux: fast indexed search

Updated July 3, 2026

The locate command finds files through a prebuilt index of names.

Syntax

locate name

Common cases

locate sshd_config     # find a file by name
locate -i readme       # ignore case
sudo updatedb          # rebuild the system-wide index
locate -c .conf        # how many matches

How it works: an index versus walking the tree

find walks the directory tree live every time - accurate, but slow. locate reads an index (a name database) built by the updatedb command, usually scheduled once a day. So locate answers instantly but cannot see files created since the last updatedb. The rule is simple: if the file is fresh, use find; to look up a long-standing file by name, locate is faster.

Used in

You need this in the lesson Finding files. The theory is the chapter Finding files: find, locate, which.

See also

The find command, which, type, whereis.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.