locate(1)
โจ locate(1) โ find files by name, bestie โจ
okay so like, this is the locate manpage from the General Commands Manual. it's giving "where is that file tho" energy and honestly? iconic. let's get into it ๐
๐ธ NAME ๐ธ
locate โ find files by name. that's it. that's the whole vibe. you're looking for a file, locate finds it, slay.
๐ SYNOPSIS ๐
locate [OPTION]... PATTERN...
๐ฆ DESCRIPTION ๐ฆ
so here's the tea, bestie: locate reads one or more databases that were prepared by updatedb(8) โ like, someone else did the homework and now you get to just look at the answers โ and then it writes file names that match at least one of the PATTERNs to standard output, one per line. literally just handing you the list. ๐ซถ
okay but here's where it gets interesting (no cap): if you don't specify --regex, your PATTERNs can contain globbing characters. and if any PATTERN contains no globbing characters, locate behaves as if the pattern were *PATTERN*. so like, it auto-wraps your search in wildcards so you don't have to. thoughtful queen behavior โจ
โ ๏ธ important caveat, don't come for me: by default,locatedoes not check whether files found in the database still exist. (but it does require all parent directories to exist if the database was built with--require-visibility no.) and like,locatecan never report files created after the most recent update of the relevant database. so if your file is brand new? it's not in the database yet. the database is not a time traveler. ๐
๐ฅ EXIT STATUS ๐ฅ
locate exits with status 0 if any match was found, OR if locate was invoked with one of the --limit 0, --help, --statistics or --version options. like, even if you found nothing, if you used one of those, you're still good. we love a forgiving exit. ๐
if no match was found or a fatal error was encountered, locate exits with status 1. rip.
and heads up: errors encountered while reading a database are not fatal โ search continues in other specified databases, if any. so like, one database is being messy? the others still get searched. resilience. ๐ช
โจ OPTIONS โจ
okay this is the part where we go through every single flag because we do not skip. periodt. ๐
-A,--allโ Print only entries that match allPATTERNs instead of requiring only one of them to match. so like, AND instead of OR. picky but make it fashion. ๐-b,--basenameโ Match only the base name against the specified patterns. this is the opposite of--wholename. so like, just the filename, not the whole path. ๐-c,--countโ Instead of writing file names on standard output, write the number of matching entries only. just the count, bestie. no names. ๐ข-d,--database DBPATHโ Replace the default database withDBPATH.DBPATHis a:-separated list of database file names. if more than one--databaseoption is specified, the resulting path is a concatenation of the separate paths. so you can stack 'em. ๐๏ธ- An empty database file name is replaced by the default database.
- A database file name
-refers to the standard input. - Note that a database can be read from the standard input only once. so don't try to rewind it, it's not a tape. โช
-e,--existingโ Print only entries that refer to files existing at the timelocateis run. like, filtering out the ghosts. ๐ป-L,--followโ When checking whether files exist (if the--existingoption is specified), follow trailing symbolic links. this causes broken symbolic links to be omitted from the output. so broken symlinks get yeeted from the results. ๐ซก- This is the default behavior. The opposite can be specified using
--nofollow.
- This is the default behavior. The opposite can be specified using
-h,--helpโ Write a summary of the available options to standard output and exit successfully. your little cheat sheet. ๐-i,--ignore-caseโ Ignore case distinctions when matching patterns.FILEandfileare the same thing, we don't discriminate. ๐-l,--limit,-n LIMITโ Exit successfully after findingLIMITentries. if the--countoption is specified, the resulting count is also limited toLIMIT. so like, you can cap the vibes. ๐-m,--mmapโ Ignored, for compatibility with BSD and GNUlocate. it's just there to be polite. ๐-P,--nofollow,-Hโ When checking whether files exist (if the--existingoption is specified), do not follow trailing symbolic links. this causes broken symbolic links to be reported like other files. so the broken ones show up instead of getting hidden. ๐- This is the opposite of
--follow.
- This is the opposite of
-0,--nullโ Separate the entries on output using the ASCII NUL character instead of writing each entry on a separate line. this option is designed for interoperability with the--nulloption ofxargs(1). so if you're piping into xargs, this is your moment. ๐-S,--statisticsโ Write statistics about each read database to standard output instead of searching for files and exit successfully. numbers, not names. data queen. ๐-q,--quietโ Write no messages about errors encountered while reading and processing databases. silence is golden. ๐คซ-r,--regexp REGEXPโ Search for a basic regexpREGEXP. NoPATTERNs are allowed if this option is used, but this option can be specified multiple times. so you can stack regexps but not patterns. pick a lane. ๐ง--regexโ Interpret allPATTERNs as extended regexps. different flavor of regex, same drama. ๐-s,--stdioโ Ignored, for compatibility with BSD and GNUlocate. another polite ghost. ๐ป-V,--versionโ Write information about the version and license oflocateon standard output and exit successfully. the receipts. ๐งพ-w,--wholenameโ Match only the whole path name against the specified patterns. the full path, not just the base. ๐ค๏ธ- This is the default behavior. The opposite can be specified using
--basename.
- This is the default behavior. The opposite can be specified using
๐ EXAMPLES ๐
so like, say you wanna search for a file named exactly NAME (not *NAME*), here's the move:
locate -b '\NAME'
because \ is a globbing character, this disables the implicit replacement of NAME by *NAME*. so the backslash is doing the heavy lifting. iconic. ๐ซถ
๐ FILES ๐
/var/lib/mlocate/mlocate.dbโ The database searched by default. that's the one. the main character database. ๐
๐ธ ENVIRONMENT ๐ธ
LOCATE_PATHโ Path to additional databases, added after the default database or the databases specified using the--databaseoption. so it's like, extra databases appended to the list. ๐๏ธ
๐ NOTES ๐
okay these notes are important, don't skip them just because they're at the bottom. bestie please. ๐
- The order in which the requested databases are processed is unspecified, which allows
locateto reorder the database path for security reasons. so like, don't assume order. it's for your own good. ๐ locateattempts to be compatible toslocate(without the options used for creating databases) and GNUlocate, in that order. this is the reason for the impractical default--followoption and for the confusing set of--regexand--regexpoptions. so like, the weirdness has lore. ๐- The short spelling of the
-roption is incompatible to GNUlocate, where it corresponds to the--regexoption. Use the long option names to avoid confusion. so like,-rmeans different things in different places. don't get got. โ ๏ธ - The
LOCATE_PATHenvironment variable replaces the default database in BSD and GNUlocate, but it is added to other databases in this implementation andslocate. so like, different behavior in different implementations. iykyk. ๐
๐ฆ AUTHOR ๐ฆ
Miloslav Trmac <mitr@redhat.com> โ thank you for your service. ๐ซก
โญ SEE ALSO โญ
updatedb(8)โ the one that actually builds the database. the behind-the-scenes queen. ๐
and that's the whole page, bestie! this was mlocate, dated Sep 2012, and honestly? it ate. ๐
โจ no cap, fr fr. now go find those files. ๐ฆ๐
๐ฆ where this page comes from
- alpine 3.24: mlocate-doc 0.26-r9 ยท GPL-2.0-only
- centos-stream 9: mlocate 0.26-31.el9 ยท GPLv2
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 ยท GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 ยท GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 ยท GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 ยท GPL-2.0-only
- Copyright (C) 2012 Red Hat, Inc. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms