17

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

user3139774
  • 1,295
  • 3
  • 13
  • 24

2 Answers2

41

To install the locate package, use yum:

$ yum install mlocate

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

$ updatedb
l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • 1
    Please make note that in RHEL 8 / Centos 8 up until now the `mlocate-updatedb.timer` service in `systemctl` was not enabled during installation, so it [would not persist between boots](https://bugzilla.redhat.com/show_bug.cgi?id=1817591). ...and it is [run by SystemD, not `cron.daily`](https://bugzilla.redhat.com/show_bug.cgi?id=1697244). Run `systemctl enable mlocate-updatedb.timer` until the patch is in place from upstream. – sastorsl Aug 26 '20 at 10:19
0

Step 1: Go to the /etc/yum.repos.d/ directory.

cd /etc/yum.repos.d/

Step 2: Run the below commands

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i  's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Step 3: Now run the yum update

yum update -y
Vineesh Vijayan
  • 570
  • 4
  • 15