How to install locate command in Linux Redhat and Centos

To install the locate command (mlocate) in Redhat or Centos, use the ’YUM’ command, install function. 

  • Logon as ‘root’ or use with ‘sudo’ permissions
  • Then, run a ’man’ command to confirm that the locate command is not already installed: ‘man locate’

Example ‘man’ command (as root user)

[root@blog-server ~]# man locate

  • If the ’man’ documentation page returns, then it is already installed.  If no ’man’ documentation page is returned, then run the ‘yum install’ command.
  • Run the ‘yum install’ command as ‘root’ or ‘sudo’ user:

Example ‘yum install’ command (as root user)

[root@blog-server ~]# yum install mlocate

Example ‘yum install’ command (as sudo user)

[root@blog-server ~]# sudo yum install mlocate

Then run the [root@data-server ~]# updated

Example Run ‘updatedb’ Command (as Root user)

[root@blog-server ~]# updated

Example Run ‘updatedb’ Command (as sudo user)

[root@blog-server ~]# sudo updatedb

Linux – What is yum?

Linux
Linux

In simple terms, yum is a, command-line interface, package manager utility for computers running the Linux operating system, which augments the RPM Package Manager capabilities. yum is the primary tool for getting, installing, deleting, querying, and managing RPM software packages. Also, yum is used in Red Hat Enterprise Linux (RHEL) versions 5 and later.