A modern search tool
Command Line – plocate

© Lead Image © Author, 123RF.com
As the latest successor to locate, plocate produces some of the quickest search results possible on any system.
Real estate agents sometimes say that the key to success is location, location, location. This saying might almost summarize the history of the locate
command [1] and its various successors, particularly mlocate
[2] and plocate
[3]. As a replacement for find
, all three commands use a database solution to reduce search time. While all three share many of the same options, plocate
is widely considered the most efficient choice.
Slightly different versions of locate
are available in the BSD and GNU findutils, but you can also find locate
, mlocate
, and plocate
as separate commands. Because the number of choices can be confusing, a history seems in order. First released in 1982, locate
uses a database that can be read by any user. If regular expressions are not used, it displays every instance of the string entered on the system, which is inconvenient if the string is common. However, locate
's most serious limitation is that the database has to be updated manually. Largely because of these problems – especially the need for manual updates – locate
was succeeded briefly by slocate
(secure locate) [4] until replaced in 2006 by mlocate
(merging locate). Both slocate
and mlocate
are an improvement over locate
in that they contain the utility updatedb
[5] to update databases, speeding up the process by only searching for files and directories where the ctime
has changed. Also, both slocate
and mlocate
show only the files that the current user has access to, thereby improving security, and they allow regular expressions to be used without a specific option. Written by Miloslav Trmac while he participated in the Google Summer of Code, mlocate
became the preferred version until 2020, although it seems to have gone through periods of being unmaintained.
Named for the posting lists that inspired it, plocate
was written to be a drop-in replacement for mlocate
. While it can still use updatedb
to create its database, plocate
can also use the plocate-build
utility [6] to create an index when a root user is logged in. Unlike mlocate
, when multiple strings are searched, plocate
returns only the files that match all the search strings, rather than any file that matches even one string. Another difference from mlocate
: plocate
is compatible with systemd and SELinux. Instead of scanning every entry one at a time, plocate
scans trigrams (i.e., combinations of three bytes at a time) to increase search speeds. Although specifically designed for solid state drives (SSDs), on older hard drives, plocate
can gain further speed by using the io_uring
Asynchronous I/O (AIO) framework introduced in the Linux 5.1 kernel in March 2019 [7]. As its main limitation, plocate
's benefits may be lost when searching for strings shorter than three bytes, for non-UTF-8 file names, or for regular expressions with numerous hits. Usually, its enhancements mean that plocate
can find two files out of 27 million in .008 milliseconds, while mlocate
takes 20.118 milliseconds for the same operation [8]. Even though locate
and mlocate
are still available, in most circumstances, plocate
should be the preferred variant.
[...]
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

News
-
Fedora 42 Available with Two New Spins
The latest release from the Fedora Project includes the usual updates, a new kernel, an official KDE Plasma spin, and a new System76 spin.
-
So Long, ArcoLinux
The ArcoLinux distribution is the latest Linux distribution to shut down.
-
What Open Source Pros Look for in a Job Role
Learn what professionals in technical and non-technical roles say is most important when seeking a new position.
-
Asahi Linux Runs into Issues with M4 Support
Due to Apple Silicon changes, the Asahi Linux project is at odds with adding support for the M4 chips.
-
Plasma 6.3.4 Now Available
Although not a major release, Plasma 6.3.4 does fix some bugs and offer a subtle change for the Plasma sidebar.
-
Linux Kernel 6.15 First Release Candidate Now Available
Linux Torvalds has announced that the release candidate for the final release of the Linux 6.15 series is now available.
-
Akamai Will Host kernel.org
The organization dedicated to cloud-based solutions has agreed to host kernel.org to deliver long-term stability for the development team.
-
Linux Kernel 6.14 Released
The latest Linux kernel has arrived with extra Rust support and more.
-
EndeavorOS Mercury Neo Available
A new release from the EndeavorOS team ships with Plasma 6.3 and other goodies.
-
Fedora 42 Beta Has Arrived
The Fedora Project has announced the availability of the first beta release for version 42 of the open-source distribution.