LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   locate : command not found (https://www.linuxquestions.org/questions/linux-newbie-8/locate-command-not-found-657872/)

prakash.akumalla 07-24-2008 01:50 AM

locate : command not found
 
Hi,

locate, whereis commands are not working on my centos box. When ever i give locate file_name the out put is locate:command not found.

After this i tried to install it by giving

yum install locate

the output is

Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Nothing to do

Please help me in this issue.

Please also tell me how can we find rpm package for a command, so that when ever it says that this command not found i can directly install the package so that it works.

Thanks,
Prakash.

indeliblestamp 07-24-2008 04:25 AM

I'm on a redhat derivative now, and in mine the package is called slocate, not locate. Try yum install slocate and see if that helps.
I'm not too sure on this next bit, but I think yum search locate will search through the repos and give you all the package names where the text 'locate' is found. Or maybe its yum list locate.

prakash.akumalla 07-24-2008 05:39 AM

Hi,
Thanks for your concern but it did not work.
The output is the same as earlier saying that nothing to do.

Prakash.

indeliblestamp 07-24-2008 05:46 AM

Google is your friend.
The package is now called mlocate apparently. Did you try the yum search command?

unSpawn 07-24-2008 05:46 AM

If you made sure you yum repos are configured OK, then try 'yum -y install mlocate'. And please fill in at least your distro+release info in your profile.

prakash.akumalla 07-24-2008 05:54 AM

hi,
Sorry to say that there is no difference after using

yum install mlocate and
yum -y install mlocate

the output is the same as earlier.

Will be there any RPMs for these so that we can directly download those and use

Thanks,
Prakash.

unSpawn 07-24-2008 06:04 AM

The package name is either "slocate" (old) "mlocate" (new). You can find it by browsing the repo (mirror) or through Pbone, Rpmfind or your favourite searchengine. What repos are configured in /etc/yum.repo.d/ for your machine and what CentOS version are you using?

sir_com 07-24-2008 06:15 AM

run the command

rpm -qa|grep -i locate

this will tell you whether locate or slocate RPM is installed in your machine. I believe it's not installed and in that case try installing the package either from web or from the media from where you have installed your OS.

Check out this site....most probably you will get the package you are searching for

http://rpm.pbone.net/index.php3/stat...om/CentOS.html

Cheers
sir_com

sir_com 07-24-2008 06:17 AM

ohh!!! forgot to mention....once you download the RPM successfully on your local machine...install it using

rpm -ivh <rpm-name> --nodeps

prakash.akumalla 07-24-2008 06:20 AM

Hi,
I am using centos 5.2
I think you can find the error now. Now when i use locate command the output is

locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory

thanks,
Prakash.

unSpawn 07-24-2008 06:43 AM

By default that database is updated daily from a cronjob in /etc/cron.daily. Locate (heh) the cronjob, then issue the command manually.

salasi 07-24-2008 06:48 AM

You've now got locate installed, but you haven't built a database. You need 'updatedb' to do this (probably need to be root to do it).

Just for your further information, you could be more helpful when you are saying that something doesn't work. For example, you could include whether there was any output when you ran the rpm commands and not just what happened when you tried to run the final command itself.

prakash.akumalla 07-24-2008 07:34 AM

Hi,
Thanks for your help. It works after running the code in /etc/cron.daily/

Is this the same in case of whereis command also?

But there is no file related to whereis in /etc/cron.daily

Please help me to resolve this also.

Thanks,
Prakash.

unSpawn 07-25-2008 06:25 AM

No, 'whereis' doesn't use a database like 'locate' or 'whatis' slash 'apropos'. I think it would be good for you to read Rute and the CentOS Deployment docs (the Deployment_Guide-en-US-5.2-11.el5 package contents). Much basic info there.

TimoRiikonen 07-16-2014 01:53 AM

Summary of explanations here
 
Some of the hints are better and some are not, so here is a summary about locate:
- The command name is still "locate"
- But when you install it, you need to install it with "yum install mlocate" command
- After that either wait for tomorrow :-) or give command "updatedb". This collects folder and file names to a database, which is the reason everyone wants to use locate instead of find: it is dozens of times faster.

And no need to do:
- Check your cronjobs - you will just find the updatedb command from there.
- Do RPM installation - if you use yum, then it will do the installation always as well


All times are GMT -5. The time now is 01:14 AM.