Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a complete unix noob so please forgive my simple question. 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. Could anyone provide any help for me with this problem?

share|improve this question
up vote 7 down vote accepted

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):

$ echo $PATH

You have several choices; while #1 and #2 involve less advanced concepts, I recommend #3 which is less work in practice:

  • You can put the executable in a directory that's already on your PATH. For example, if /home/drbunsen/bin is already on your PATH, 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 changing PATH 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:

    cd ~/bin
    ln -s ../meme/bin/* .

    That's assuming that ~/bin is already on your PATH; 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.

share|improve this answer
Gilles, wow thank you SO MUCH for the detailed explanation. I really appreciate your help. Thanks for taking the time to answer my question in detail and at a level that made everything crystal clear. – dr.bunsen Jul 7 '11 at 22:41
Another thing that I noticed is that in the home/meme/ directory there doesn't appear to be a /bin directory. Do I need to create bin so that I can make a symbolic link in here to my PATH? Thanks. – dr.bunsen Jul 7 '11 at 22:49
@dr.bunsen ~/bin is a common location, and some distributions create it automatically. If yours doesn't, you'll have to create it and add it to PATH manually. The location ~/bin is just a convention, you can pick another name if you like. – Gilles Jul 7 '11 at 22:56
The wildcard command does not work because ln interprets the last item in the expansion as a directory: "Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form) or: ln [OPTION]... TARGET (2nd form) or: ln [OPTION]... TARGET... DIRECTORY (3rd form) or: ln [OPTION]... -t DIRECTORY TARGET... (4th form) " To solve this, I added "-t ./" – adam.r May 25 '14 at 22:18
@adam.r I wrote ln -s ../meme/bin/* ., not ln -s ../meme/bin/*. Looks like you missed one character when copying the command. – Gilles May 25 '14 at 22:19

You can add the new directory to your PATH temporarily, meaning for the duration of the current terminal session, with

$ export PATH=$HOME/meme/bin:$PATH

This adds the new directory to the beginning of the PATH variable, while retaining all existing directories.

If you want the modification to take effect permanently, in all future terminal sessions, you need to add the above line to the appropriate profile file in your home directory. Depending on how your distribution is set up, this might be called ~/.bash_profile, ~/.profile or something similar.

Note also that you do not need to add a directory to your $PATH in order to execute a program inside it, you can also invoke the program by giving its full path, e.g.

$ $HOME/meme/bin/program_name


$ ./program_name

if it is in the current directory.

share|improve this answer
~/.bashrc isn't the place to put environment variable definitions; see Difference between .bashrc and .bash_profile – Gilles Jul 7 '11 at 20:35
@Gilles - you're right, edited. – TooManyKooks Jul 7 '11 at 21:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.