Help Docs Server Administration Linux Server Administration Installing mlocate

Installing mlocate

The locate command is one of the best tools for finding files quickly by filename. This command reads one or more databases prepared by updatedb and writes files matching at least one of the patterns to standard output (one per line). You may need to install mlocate to enable this feature. This article provides instructions for installing mlocate on CentOS and Fedora.

The locate command is one of the best tools for finding files quickly by filename. This command reads one or more databases prepared by updatedb and writes files matching at least one of the patterns to standard output (one per line).

Instructions for installing mlocate will depend on your operating system, choose from the list below to see the instructions for your system.

Note:


You need to be logged into your server as root. All instructions shown are from the command line. If you’re unsure how to log in as root, see our article Logging into Your Server via Secure Shell (SSH).


Install on CentOS 6 & 7

  1. Before installing mlocate, it is best practice to update your packages:
    yum -y update

  2. Next, install mlocate and all required packages:
    yum -y install mlocate

  3. To update the search databases, use the following command:
    updatedb

mlocate also installs a cron job which will run daily to update search databases at:

/etc/cron.daily.mlocate.cron

For more information regarding Cron, check out our article Automating Server Scripts with Cron.

Install on Fedora 23

  1. To update your packages, run the following command:
    dnf -y update

  2. Then install mlocate and any required packages:
    dnf -y install mlocate

  3. Once mlocate is installed, a systemd timer is also installed to regularly update the search database. But if you’d like to manually trigger an update, you can use the following command:
    updatedb

Was this article helpful?