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
-
SUSE Dives into the Agentic AI Pool
SUSE becomes the first open source company to adopt agentic AI with SUSE Enterprise Linux 16.
-
Linux Now Runs Most Windows Games
The latest data shows that nearly 90 percent of Windows games can be played on Linux.
-
Fedora 43 Has Finally Landed
The Fedora Linux developers have announced their latest release, Fedora 43.
-
KDE Unleashes Plasma 6.5
The Plasma 6.5 desktop environment is now available with new features, improvements, and the usual bug fixes.
-
Xubuntu Site Possibly Hacked
It appears that the Xubuntu site was hacked and briefly served up a malicious ZIP file from its download page.
-
LMDE 7 Now Available
Linux Mint Debian Edition, version 7, has been officially released and is based on upstream Debian.
-
Linux Kernel 6.16 Reaches EOL
Linux kernel 6.16 has reached its end of life, which means you'll need to upgrade to the next stable release, Linux kernel 6.17.
-
Amazon Ditches Android for a Linux-Based OS
Amazon has migrated from Android to the Linux-based Vega OS for its Fire TV.
-
Cairo Dock 3.6 Now Available for More Compositors
If you're a fan of third-party desktop docks, then the latest release of Cairo Dock with Wayland support is for you.
-
System76 Unleashes Pop!_OS 24.04 Beta
System76's first beta of Pop!_OS 24.04 is an impressive feat.

