I have a unix executable file located in a directory I generated. I believe I need to get this directory in my $PATH
so that the unix executable is executable, but the documentation for the source code says that I need to edit my shell configuration file to add $home/meme/bin
to my shell's path.
Problem with $PATH and executable file
executablepath
Best Answer
If you want to be able to execute a program by typing its name on the command line, the program executable must be in one of the directories listed in the
PATH
environment variable. You can see the current value of the variable like this ($
is your prompt, and the value below is an example):You have several choices; while #1 and #2 involve less advanced concepts, I recommend #3 which is less work in practice:
PATH
. For example, if/home/drbunsen/bin
is already on yourPATH
, you can put the executable there. Or you can put the executable in/usr/local/bin
if you want it to be available for all users.You can add the directory where the executable is in your
PATH
. Edit the file~/.profile
(~/
means that the file is in your home directory) (create the file if it doesn't exist). Add a line like this:(Note that it's
$HOME
, not$home
; unix is generally case-sensitive. You can also write~/meme/bin
,~
is a synonym for$HOME
when it's at the beginning of a file path.) The change will take effect the next time you log in. You can type this same line in a terminal, and it will affect the shell running in that terminal and any program launched from it.The approach I recommend is to keep the executable with the other files that are part of the program, in a directory of its own, but not to change
PATH
either.Keeping the executable in
$HOME/meme
has the advantage that if you ever want to remove or upgrade the program, everything is in one place. Some programs even require this in order to find the files they use. Not changingPATH
has the advantage that installing and uninstalling programs is less work.To get the best of both worlds, create a symbolic link in a directory on your
PATH
, pointing to the actual executable. From the command line, run a command like this:That's assuming that
~/bin
is already on yourPATH
; if it's not, add it through~/.profile
as indicated above. Pick another location if you like. Now making programs available is a matter of creating the symbolic links; making them unavailable is a matter of removing the symbolic links; and you can easily track what programs you've installed manually and where they live by looking at the symbolic links.