The plocate Command as a Faster Alternative to locate in Linux

The plocate command finds all files on the system matching the given pattern, providing much faster searches on a smaller index.

When you need to search for some files in Linux, you might typically use find or locate commands. So, now you have a new alternative called plocate.

plocate works by creating an inverted index over trigrams (combinations of three bytes) in the search strings, which allows it to rapidly narrow down the set of candidates to a tiny list instead of linearly scanning through every entry.

Named for the posting lists that inspired it, the plocate command aims 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 to create an index.

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.

To show how fast the plocate command is, the developer offers this benchmark on the tool’s homepage in which plocate can find two files out of 27 million in just a few milliseconds:

plocate command

The tool quickly gained popularity. For example, Fedora 36 plans to use plocate as its new provider of the locate command for finding files on file systems.

Install

Debian 11 Bullseye and newer, Debian 10 Buster backports, Ubuntu 21.04, 21.10, and 22.04:

sudo apt install plocate

Arch Linux and its derivatives:

sudo pacman -S plocate

Fedora:

sudo dnf install plocate

How to Use plocate

Now you can start using plocate. First, you need to create its database (file index):

sudo updatedb

Firing the plocate command to look for a file is straightforward. For example, to search for a file named backup.py you would type:

plocate backup.pyCode language: CSS (css)
plocate find files

If there are files you cannot find, there are two likely culprits:

1. First, check that the database has been updated recently. Most users will want to use plocateโ€™s updatedb.

There is a service and a timer to update the database regularly. You can enable it, and it will automatically trigger the service with:

sudo systemctl enable plocate-updatedb.timer
sudo systemctl start plocate-updatedb.timerCode language: CSS (css)

2. The other reason a file isnโ€™t shown is typically permissions. Check if you can find the files as root, and if you can, the problem is most likely that you donโ€™t have access rights to the directory down from the root.

For more about the plocate command in Linux, consult its manual page. 

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%