So i'm fooling around with the Terminal.
Can someone explain to me how to install a program by putting it's Binary in my PATH.
I am assuming I go $PATH/ --Binary--
If the above is the case,
1) Why does this install the program?
2) Is there a standardized method to find a 'downloads' binary?
I am sure there are better ways of installing programs. I am interested in this specific method though.
Thanks in advance for your help.
The PATH is a shell variable that tells the shell where programs may be found. It is a list of places to look for executable programs and scripts, separated by colons (:
). For example:
PATH=/bin:/sbin:/usr/local/bin
So, when you run a program by typing:
program
the shell looks first in /bin
, then in /sbin
and so on, until it finds program
, then it runs that.
So, if you want to install a binary (or program, or script) just put it anywhere on your PATH. Or put it somehwere new, not on your PATH, and change your PATH to tell the shell where you have put it.
In general, you would want to set your PATH in your login profile, which may be ~/.profile or elsewhere so that it is set each time you log in. To do that, add a line like this:
export PATH=$PATH:/some/additional/place
If you want to find out which is the actual program that will be run when you type
program
you can run
which program
For example, if you want to know which sed
you are running, type
which sed
and it will probably tell you somethimg like
/usr/bin/sed
Regarding your second question, about a standard downloads area
, I am not sure if you mean a standard place to find binaries, or a standard place to install them. There is no standard downloads
area to obtain binaries, though for Mac OSX, many people use homebrew
or macports
. If you mean a standard place to put them, it is normal to install software that doesn't come from the OS author, into /usr/local/bin
, so that all local binaries are separate from those issued with the OS itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With