Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centos - "locate" command doesn't work

We have Centos 7.
Trying to use the 'locate' command yields nothing, even if the searched file[s] actually exist.
No error is printed.
Also executed 'sudo updatedb' to update the 'locate' indexes.

Any ideas?

Thank you

like image 430
user3139774 Avatar asked May 15 '16 05:05

user3139774


People also ask

Why locate command is not working?

If the locate command is not already installed on your system, you will encounter an error such as locate command not found or bash: /usr/bin/locate: No such file or directory when trying to execute the command. The simple solution to this problem is to install locate with your system's package manager.

How does locate command work?

The locate command finds files in Linux using the file name. locate is used for obtaining instantaneous results, and it is an essential utility when speed is a priority. The command performs the search using a database containing bits of files with the corresponding paths in the system.

How do you find a file in Linux using locate command?

The syntax for the locate command is as follows: locate [OPTION] PATTERN... In its most basic form, when used without any options, the locate command will print the absolute path of all files and directories that matches the search pattern and for which the user has read permission. The /root/.

Why is locate command not found in Linux?

Installing locate (locate command not found) Depending on the distribution and how the system was provisioned, the locate package may or may not be pre-installed on your Linux system. To check whether the locate utility is installed, open up your terminal, type locate and press Enter.

What is the use of locate in Linux?

The locate command searches the file system for files and directories whose name matches a given pattern. The command syntax is easy to remember, and results are shown almost instantly. For more information about all available options of the locate command type man locate in your terminal.

How to find files in CentOS/RHEL systems?

On most CentOS/RHEL systems, findutils comes pre-installed, however, if you try to run a locate command, you may encounter the error: In this article, we will show you how to install mlocate package which provides the locate and updatedb commands to find files in Linux systems.

What to do if locate is not installed?

If locate is not installed, you can easily install it using the package manager of your distro. The locate command searches for a given pattern through a database file that is generated by the updatedb command.


1 Answers

To install the locate package, use yum:

$ yum install mlocate

To update it’s "internal database", run following command.

$ updatedb
like image 177
l'L'l Avatar answered Oct 06 '22 23:10

l'L'l