How to debug `locate` command?

50 views Asked by At

I have a directory call mosesdecoder in my home directory and when I try to locate it, it can't be found. The directory is newly created.

I have tried locating a previously created directory and the locate command works.

I have already tested the locate by creating a new directory and locating it but it doesn't locate the directory

alvas@ubi:~$ ls
examples.desktop
Templates
mosesdecoder
Desktop            
Documents          
Public                        
Videos
Downloads           
workspace
alvas@ubi:~$ locate 'mosesdecoder' | head -n1
alvas@ubi:~$ 
alvas@ubi:~$ locate 'workspace' | head -n1
/home/alvas/workspace
alvas@ubi:~$ locate 'Documents' | head -n1
/home/alvas/Documents
alvas@ubi:~$ mkdir testlocate
alvas@ubi:~$ locate 'testlocate'
alvas@ubi:~$ 

Is there a reason why locate doesn't locate newly created directories?

Is there an index that the locate command searches from?

How do I debug the locate command?

What should I do such that newly created directories are "locate-able"?

1

There are 1 answers

0
jim mcnamara On BEST ANSWER

Use updatedb to update the locate databases.

locate can "find" only the entries in the database, so it needs updating periodically.

Edit: more information about locate and locatedb and how it all works. http://linux.about.com/od/commands/l/blcmdl5_locatedb.htm