locate command in Linux: fast indexed search
Updated July 3, 2026
The locate command finds files through a prebuilt index of names.
Syntax
locate nameCommon 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 matchesHow it works: an index versus walking the tree
findwalks the directory tree live every time - accurate, but slow.locatereads an index (a name database) built by theupdatedbcommand, usually scheduled once a day. Solocateanswers instantly but cannot see files created since the lastupdatedb. The rule is simple: if the file is fresh, usefind; to look up a long-standing file by name,locateis 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.