Msg#: 4098931 posted 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" /usr/bin/vmware-config-tools.pl OK ! [root@localhost /]# locate "*mware-config*" /usr/bin/vmware-config-tools.pl OK ! [root@localhost /]# locate "*mware-config-tool*.pl" /usr/bin/vmware-config-tools.pl OK !
Msg#: 4098931 posted 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.
Msg#: 4098931 posted 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.
Msg#: 4098931 posted 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.
Msg#: 4098931 posted 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.
Msg#: 4098931 posted 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!