LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   locate: can not open (https://www.linuxquestions.org/questions/linux-newbie-8/locate-can-not-open-759948/)

rcmonroig 10-05-2009 11:08 PM

locate: can not open
 
Running into a problem with the locate command. When I try to use the locate command: locate *.h
I get the following error message:
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory

I have a lot of include files in /usr/include
and I locate responds to whereis.

Does anyone know whats happening? Any help would be appreciated.

Ron

dv502 10-05-2009 11:18 PM

Try running the updatedb command as root.

If you're using ubuntu or any of its derivatives, type

sudo updatedb

Note: You need to run this command when you add new files and/or programs to your linux system. This step is optional. But it must be run the first time before using the locate command.

When the updatedb finished, try the locate again.

Tip: Add the -i option to locate for case insensitive search.

locate -i keyword

lutusp 10-06-2009 03:14 AM

Quote:

Originally Posted by rcmonroig (Post 3709072)
Running into a problem with the locate command. When I try to use the locate command: locate *.h
I get the following error message:
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory

I have a lot of include files in /usr/include
and I locate responds to whereis.

Does anyone know whats happening? Any help would be appreciated.

Ron

Try this:

# updatedb (as root) (if you have problems locating something you know exists)

Then:

$ locate "*.h"

Note the quotes -- this will prevent shell expansion of your argument, so "locate" sees it as you intended regardless of the content of the current directory.


All times are GMT -5. The time now is 10:24 AM.