homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

Linux locate bug

 5:44 pm on Mar 16, 2010 (gmt 0)

I am new to Linux and am running a Centos 5 distribution to get up to speed. One thing which I have found extremely frustrating on the first day is the inconsistencies with a simple command like "locate". See the commands below with OK! for success and FAILED! for the inconsistency ... :

[root@localhost /]# locate "*mware-config*.pl"
OK !
[root@localhost /]# locate "*mware-config*"
OK !
[root@localhost /]# locate "*mware-config-tool*.pl"
OK !

[root@localhost /]# locate "vmware*.pl"
[root@localhost /]# locate "vmware*"
[root@localhost /]# locate "vmware-config*.pl"
[root@localhost /]# locate "vmware-config-*.pl"

This is UTTERLY INCONSISTENT! Why does the trailing * wildcard not deliver the file ? Much appreciated if anyone can assist :-)



 12:31 am on Mar 17, 2010 (gmt 0)

First of all a warm welcome to WebmasterWorld joecarter!

Locate doesn't find files based on their basename, but based on their full path stored in a local database which is periodically compiled with the updatedb task. The regular expression parameter you pass to the locate tool must match a whole line in the database. vmware*.pl doesn't match any of the entries, because they are all full paths beginning with a slash. Therefore a wildcard at the beginning is necessary. It matches the path part of the file location.

You can also use real-time searching where you can specify a basename only. For example:

find / -name "vmware*.pl" -print

This command performs a search through the whole directory structure instead of a precompiled database and will therefore take more time than a search with the locate utility.


 1:44 pm on Mar 17, 2010 (gmt 0)

Thanks Lammert. This is crystal clear.
Nice would be if was this clear in the "man" online :-)


 1:48 pm on Mar 17, 2010 (gmt 0)

this might also help.
from the man page:
whereis locates source/binary and manuals sections for specified files. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext, for example, .c. Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in a list of standard Linux places.


 8:11 pm on Mar 17, 2010 (gmt 0)

The problem with whereis is, that it was desigined in the old Unix times when disk access was a time consuming operation. It therefore only searches in some default system paths like /bin, /etc and /usr/*. Files in one of the user directories or in an application specific directory can't be found with whereis.


 9:12 pm on Mar 17, 2010 (gmt 0)

it's not a problem - just one more tool in the bag.
i've been on servers where one or the other is not installed or the path where one is located is not specified in $PATH so you can sometimes use another one instead of or to find the other.


 1:17 pm on Mar 18, 2010 (gmt 0)

Thanks all. I must say after jsut trying the whereis cmd I find it unclear too (which is how this thread started). if I type whereis 'Red Hat-release' I get a response:
Red Hat-release:
on the next line. what does this mean .. well actually it means the file is not there ... pretty unusable feedback!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved