LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2012, 07:00 PM   #1
AsherSevyn
LQ Newbie
 
Registered: Jul 2010
Posts: 26

Rep: Reputation: 0
PATH question.


Linux $PATH question: (because google is not being helpful) Why is the order important in your path? I get it that the path makes commands find their directories so they can run regardless of where you are but of what importance is the order of those individual directories in your path?

For example here is my echo $PATH

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/myusername/bin

What does the order matter?
 
Old 11-29-2012, 07:25 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,395

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
Because it reads the PATH in the normal (English) left to right order... so if you have 2 cmd files with the same name in different locations, it'll use the 'leftmost' occurrence.

This is why you don't have the current dir in your PATH and your personal bin dir is last; so that if you don't specify a path, you'll default to the official installed program, which hopefully has not been hacked
 
1 members found this post helpful.
Old 11-30-2012, 02:39 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,169

Rep: Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493
as above

sometimes you will have a program that COMES with it's own .so's
QT programs are good( read BAD) at that
and if your system default is INCOMPATIBLE ( it happens)

you can set the priority of "WHAT is looked at FIRST " in the $PATH

first is the folder the program is in ( think Firefox tar.gz)
then the system Default ( left to right)
THEN your Custom settings in your home folder ( also left to right)
 
Old 11-30-2012, 02:46 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Quote:
Originally Posted by John VV View Post
sometimes you will have a program that COMES with it's own .so's
Linux does not use $PATH to find .so's.
 
Old 11-30-2012, 03:11 PM   #5
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 2,292

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
On the other hand...

Although some silly applications do.
(Badly written, OMOHO.)
 
Old 12-01-2012, 01:20 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I think the important concept is that lists such as $PATH and $LD_LIBRARY_PATH (which ld does use to find shared-object libraries) are ordered lists. One can use this property to advantage, or can be tripped up by it. Knowing that it exists and its impact is the key to success. The search order is left-to-right, which seems most intuitive, given how we read and write the text of the list.
I feel certain that there are other variables 'out there' that are similarly structured but don't obey this convention, which is what makes it simply a convention (a good one, IMHO).

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH question radiodee1 Debian 12 03-16-2007 10:06 AM
PATH question satimis Linux From Scratch 5 09-15-2005 10:23 AM
question about $PATH SigningiS Linux - Newbie 17 10-27-2003 12:35 PM
Question on path PatC Linux - General 1 07-09-2002 09:17 AM
Question about PATH? eddielins Linux - General 6 04-02-2001 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration