PDA

View Full Version : [ubuntu] Logic of default $PATH's in Ubuntu



Dave.YNA
April 18th, 2014, 03:19 AM
Hello all,
Just curious if there is an interesting reason why the default paths selected in Ubuntu are selected? My appears as:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

but I have been working on a redhat machine or two at work and noticed it is quite different. It will have directories such as /bin/ and /sbin/ etc..... I assume this is probably because these directories are intented for Root. If that is so, the confusing aspect is that if I run ifconfig which is located in /sbin/ifconfig, the binary is found without specifying the directory. How can that be if it is not in my PATH?

Cheers

SeijiSensei
April 18th, 2014, 04:33 AM
It is in your path. Each of the directories is searched in order from left to right until a matching binary name is found. The /usr/local entries are at the beginning since self-compiled software is typically installed to /usr/local/bin. Presumably you would want your version of a program to be run in favor of the official version in the repository. For example, my /usr/local/bin contains self-compiled versions of mplayer and ffmpeg, so if I type "mplayer" at the prompt I get /usr/local/bin/mplayer, not /usr/bin/mplayer.

Dave.YNA
April 18th, 2014, 04:39 AM
Woops! Yeah, I missed that, it is in the path....

Thanks for the reply. I will now go get my eyes tested :P