PDA

View Full Version : How to find path to Linux programs?


amanoffewwords
30th Sep 2004, 08:40
Dear Linux-gurus,

Can someone remind the command to display the path to programs - I need to confirm where PHP is running from on my server - It's supposed to be /usr/local/lib/php.

I seem to recall it's something like "where php" or "what php" or similar and, for once, Google is no help (or I'm not searching the correct keyword).

Cheers
Charles

Evo
30th Sep 2004, 08:43
I think whereis is what you're looking for, e.g.

>evo@camel: whereis konqueror
konqueror: /opt/kde3/bin/konqueror

alternatively, you can do rpm -qpil filename.rpm to find out where it puts things - not quite what you're after, but also useful for tracking things down.

Memetic
30th Sep 2004, 08:46
Finding Files in Linux at:

http://www.comptechdoc.org/os/linux/usersguide/linux_ugfinding.html

has a good summary, I stumbled across it looking for examples of the locate command.

amanoffewwords
30th Sep 2004, 09:15
Thanks Evo - that's exactly what I was looking for.

whereis php gives me:

php: /usr/bin/php /etc/php.ini /usr/lib/php /usr/lib/php.ini
/usr/local/bin/php /usr/local/lib/php /usr/local/lib/php.ini /usr/include/php

Do you know if it's normal to have /usr/bin/php and /usr/local/bin/php - that looks like duplicate installations to me?

Thanks Memetic for the link - it has been bookmarked

drauk
1st Oct 2004, 00:03
'whereis X' will tell you if the program X is in one of the typical locations for executables.

If you want to know WHICH version of the executable X will be run if you type the command without specifyin a path then you need to use 'which X'.

Sometimes you'll find /usr/bin/php is a symbolic link to /usr/local/bin/php. To find out, examine the output of:

ls -al /usr/bin/php

If it isn't you could try:

diff /usr/local/bin/php /usr/bin/php

to see if they're the same. If they're not then try:

/usr/bin/php -version

and

/usr/local/bin/php -version

to see which version is which.

amanoffewwords
1st Oct 2004, 07:53
Thanks Drauk - which did it and you're correct about the symbolic link to /usr/local/bin/php. Just got to figure why my cron job is still not working. Just wished there was command such as
whatisthematterwithyou cron.php :)

drauk
1st Oct 2004, 11:15
I don't know much about PHP I'm afraid and it's hard to know where to look without more details of your problem. However, 2 thoughts:

1) Have you tried this simple script in order to get a lot of information about PHP and how it is configured on your system? Create a file with (just) the following:

<?php phpinfo() ?>

You can then execute this from your web browser or from the command line.

2) Problems with CRON jobs are most often related to the user environment in which they are running - mostly environment variables that are setting the user's path, default langauge, timezone etc. Try printing out the values from the script in CRON to check they are what you expect them to be.