I am trying to execute a program (Usearch or samtools) by just typing the name of the program (e.g. usearch [options]) from anywhere. I am running Ubuntu.

Instructions say to "add the binary to your path to make it available on the command line" But I don't know what that means or how to do it. A search online brought up things that were way over my head.

Could someone give me a simple step by step on how to do this?


2 Answers 2


"add the binary to your path to make it available on the command line"

In Unix, the PATH is the environment variable which defines where the shell looks for executable programs to run when you enter them on the command line. If you do a:

echo $PATH

You can see what your PATH looks like. All of the directories on the PATH are then searched (in order) when you type a command (like ls). For example, my $PATH is:


When I type in ls the shell will look for an executable in . (the current directory) and then all of the other directories until it finds it, probably in /bin/ls.

You will need to make sure your script is executable (chmod +x myscript) and then it needs to be in one of the directories in the PATH variable.

It's considered somewhat bad practice to install local scripts and programs in the system's bin directories. Typically I put something like the following in my shell's startup-config file which is .profile but could be .bashrc or .zshrc depending on the shell:

export PATH=$HOME/bin:$PATH

This will add to the path a personal bin directory in your home directory where you can put your own scripts. Once you change the shell's config file you will need to login again to have the config file read.

If you want to install your script for all of the users on your system then a better place for your script is /usr/local/bin. You should make sure that /usr/local/bin is in your path using the above mechanism.

So you need to:

  1. Make your program executable (chmod +x my-program)
  2. Maybe add your own local bin directory or /usr/local/bin to the PATH definition in your .profile.
  3. Install it in a directory in your PATH environment.
  • 1
    Thank you. I was able to use my program from my Documents folder by typing "PATH=$PATH:/$HOME/Documents". After making a bin folder (and putting my executable file in it) in my Home folder, I added the following to my .bashrc file: "export PATH=$HOME/bin:$PATH". I closed terminal and reopened it. When I type the file (e.g. usearch), it now brings up the Usage information. Jul 22, 2015 at 16:24

You will need to add the bin directory to your PATH variable.

If you type "echo $PATH" in your terminal, it will display a string of paths. Now you need to know where the installation of the programs are, and ensure that your PATH contains the appropriate bin directory. Try executing "PATH=$PATH:/Path-to-bin/" in your terminal you will now be able to execute the desired program by simply typing Usearch for example.

This may get annoying adding the bin directory to your PATH for every terminal window, luckily .bashrc (located in ~/) is run overtime you open a new terminal. So you can add your "PATH=$PATH://" line to your .bashrc, using your favourite editing program (i.e. "vim ~/.bashrc").

The .bashrc is a hidden file. So typing "ls" will not list the .bashrc, try "ls -la" to see that the .bashrc is your your home directory.

Hope this helps, let me know if you have more specific questions.

Good luck!

  • Thank you! This helped me a lot. Just to add on for any other beginners needing help: I viewed my .bashrc file by typing the following in the terminal "gedit ~.bashrc" (reference: ubuntuforums.org/showthread.php?t=2158436). I then followed the steps I put in response to Gray above. Jul 22, 2015 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .