Centos - "locate" command doesn't work
Asked Answered
G

2

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

Gorcock answered 15/5, 2016 at 5:37 Comment(0)
U
42

To install the locate package, use yum:

$ yum install mlocate

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

$ updatedb
Unreasoning answered 15/5, 2016 at 5:42 Comment(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. ...and it is run by SystemD, not cron.daily. Run systemctl enable mlocate-updatedb.timer until the patch is in place from upstream.Jiva
O
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
Oribella answered 27/3, 2022 at 6:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.