LinuxCommandLibrary

plocate

Find files quickly using indexed database

TLDR

Find files by name

$ plocate [filename]
copy
Case-insensitive search
$ plocate -i [filename]
copy
Count matches
$ plocate -c [pattern]
copy
Limit results
$ plocate -l [10] [pattern]
copy
Use regex pattern
$ plocate --regex "[.*\.pdf$]"
copy
Show only existing files
$ plocate -e [pattern]
copy
Show database statistics
$ plocate -S
copy
Update the database (as root)
$ sudo updatedb
copy

SYNOPSIS

plocate [-icle] [--regex] [-l limit] [pattern]

DESCRIPTION

plocate is a much faster replacement for mlocate, finding files by searching a pre-built database rather than scanning the filesystem in real-time.
The database (updated by updatedb, typically via cron) indexes all filenames on the system. Searches are essentially instant regardless of filesystem size - even with millions of files.
Pattern matching is substring by default: "foo" matches "/path/to/foobar.txt". Use --regex for precise matching or -b to match only the basename. Case sensitivity can be toggled with -i.
The -e option verifies files still exist before displaying, filtering out stale entries from recently deleted files. This adds overhead but ensures accurate results.
plocate uses a more compact database format than mlocate and employs posting lists for fast searching. The same updatedb database works with both tools.

PARAMETERS

-i, --ignore-case

Case-insensitive matching.
-c, --count
Print count of matches.
-l N, --limit N
Limit output to N entries.
-e, --existing
Only show existing files.
-b, --basename
Match only basename, not full path.
-w, --wholename
Match full path (default).
-r, --regex
Use POSIX extended regex.
--regex
Pattern is a regular expression.
-d PATH, --database PATH
Use specified database file.
-0, --null
Null-terminate output.
-S, --statistics
Show database statistics.
-q, --quiet
Quiet mode, exit status only.
-N, --literal
Match pattern literally.

CONFIGURATION

/var/lib/plocate/plocate.db

Default database file containing the indexed filesystem.
/etc/updatedb.conf
Configuration for updatedb controlling which paths and filesystems to index.

CAVEATS

Database must be updated regularly to reflect changes. updatedb typically runs daily via cron. New files won't appear until next update. Users can only see files they have permission to access. Database creation can be slow on first run.

HISTORY

plocate was created by Steinar H. Gunderson around 2020 as a faster alternative to mlocate. It uses techniques from information retrieval (posting lists, SIMD acceleration) to achieve 10-100x faster searches. Despite being a complete rewrite, it maintains compatibility with mlocate databases.

SEE ALSO

locate(1), mlocate(1), updatedb(8), find(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community