LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-21-2011, 02:44 PM   #1
Diamantis
LQ Newbie
 
Registered: Jan 2005
Posts: 8

Rep: Reputation: 0
Question Where whereis is searching


I am writing a script to install a program (a GUI interface) and would like to search if the required software is already installed. This made me think of the command whereis.

I was curious how the command whereis is working but didn't know where to search. Is it equivalent with a find at the most common locations?
thank you very much
 
Old 04-21-2011, 02:48 PM   #2
jcalzare
Member
 
Registered: Aug 2009
Location: Chicago
Distribution: CentOS
Posts: 114

Rep: Reputation: 34
whereis has a hard-coded path it searches for your search term. Similar to the way 'which' works, but does not use the $PATH environment variable, but rather a path determined by the distro.

From the man page:

whereis has a hard-coded path, so may not always find what you're looking for.
 
1 members found this post helpful.
Old 04-21-2011, 02:51 PM   #3
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Also from the man page:

"whereis then attempts to locate the desired program in a list of standard Linux places."
 
Old 04-21-2011, 02:54 PM   #4
Diamantis
LQ Newbie
 
Registered: Jan 2005
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jcalzare View Post
whereis has a hard-coded path it searches for your search term. Similar to the way 'which' works, but does not use the $PATH environment variable, but rather a path determined by the distro.

From the man page:

whereis has a hard-coded path, so may not always find what you're looking for.
Thanks!

So is there any other "standard" way to search for already installed software? I would like the GUI I am making to make sure the user has already installed the prerequisites.
 
Old 04-21-2011, 03:01 PM   #5
jcalzare
Member
 
Registered: Aug 2009
Location: Chicago
Distribution: CentOS
Posts: 114

Rep: Reputation: 34
Well if you have mlocate installed, you could do something like:

Code:
updatedb
locate binaryname
Obviously binaryname would be whatever software you're looking for. I guess this might not be the best solution because you'd have to make sure they have mlocate installed.. more dependencies.

Edit: You could also take the approach commonly used by configure scripts when compiling from source: Check in $PATH with something like 'which', if it's not there, tell the user they need to specify the location of the binary with flags like... --mysqldir=/var/lib/mysql

Last edited by jcalzare; 04-21-2011 at 03:03 PM.
 
Old 04-22-2011, 06:23 PM   #6
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076

Rep: Reputation: 205Reputation: 205Reputation: 205
the find command is a very flexible file locater
you can set the search path and what find will do with the results of the search
 
Old 04-22-2011, 06:35 PM   #7
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by jcalzare View Post
Well if you have mlocate installed, you could do something like:

Code:
updatedb
locate binaryname
Obviously binaryname would be whatever software you're looking for. I guess this might not be the best solution because you'd have to make sure they have mlocate installed.. more dependencies.

Edit: You could also take the approach commonly used by configure scripts when compiling from source: Check in $PATH with something like 'which', if it's not there, tell the user they need to specify the location of the binary with flags like... --mysqldir=/var/lib/mysql
2 problems with your suggestion

1 updatedb reads every directory and every file name accessible on a file system to build the data base this is extremely slow
on a fresh slackware install this can tack up to half an hour depending on the speed of the hard drive
2 locate is extremely lose on what it considers a match a file name can be 3 letters off from the searched for spelling and still be included in the search results
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Whereis yogaboy2 Linux - Newbie 6 09-07-2009 08:01 PM
'Whereis' output Ander Linux - Newbie 3 05-05-2006 05:18 AM
whereis firefox Monjawi Linux - Newbie 1 09-09-2005 05:19 PM
help : whereis mkinitrd? marsques Slackware 6 05-23-2004 03:52 PM
whereis cups tincat2 Linux - General 2 05-07-2003 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration