Updated: 28 September 2026 · Applies to: plocate 1.1 on AlmaLinux and Rocky Linux 10, RHEL 10, Ubuntu 24.04 and 26.04, Debian 13; mlocate 0.26 on AlmaLinux and Rocky Linux 9 and RHEL 9

locate finds files by name almost instantly, because it searches a database of all file names instead of walking through the disks like find. The database is refreshed once a day, so very new files may be missing until the next update. Two versions exist: plocate, the newer and faster one, and the older mlocate. Both provide the same locate and updatedb commands.

Install locate

dnf install mlocate          # AlmaLinux, Rocky Linux, RHEL 9
dnf install plocate          # AlmaLinux, Rocky Linux, RHEL 10
apt install plocate          # Ubuntu, Debian

Build the database the first time

updatedb

Run it as root. After that, a systemd timer updates the database daily (mlocate-updatedb.timer or plocate-updatedb.timer, depending on the package). Check it with systemctl list-timers | grep updatedb.

Search

locate nginx.conf                 # every path containing "nginx.conf"
locate -i readme                  # ignore upper and lower case
locate -r '/wp-config\.php$'      # exact file name only
locate -c '*.log'                 # count matches
locate -r '/var/www/.*\.php$'     # regular expression
locate -e oldfile                 # only files that still exist

A plain search matches any path that contains the text, so locate wp-config.php also finds wp-config.php.bak. The regular expression /wp-config\.php$ matches the exact file name only, with both plocate and mlocate.

locate or find?

  • locate: instant, by name only, may miss files created since the last update.
  • find: slower but always current, and can search by size, age, owner or permissions, for example find /var/www -name '*.php' -mmin -60 for PHP files changed in the last hour.

Common problems

  • "plocate.db: No such file or directory" or "can not stat () ... mlocate.db": the database does not exist yet. Run updatedb once as root.
  • A file you just created is not found: run updatedb again, or use find.
  • Folders you want to skip: add them to PRUNEPATHS in /etc/updatedb.conf.
  • Normal users do not see other users' files: that is intended; locate only shows files the user may read.

Official documentation: plocate.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)