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

Let's suppose I have compiled something and I run it like so:

$ /path/to/my/executable/mycmd
Hello World

What do I need to do to run it like

$ mycmd
Hello World 

from everywhere in my computer?

share|improve this question

What you are looking for is the PATH environmental variable. It tells the shell, where it needs to look for programs. You can see the current value of that variable using echo:

echo "$PATH"

Now... The best practice if you want use some new program is to install it using the package management program for your distribution. But in this case, I assume you are dealing with a program that is not delivered by any available software package. For such programs, you have two options:

  1. Install the program system-wide, in a place where your system does not put any files installed from packages. On most systems, such "safe" folders include /usr/local/bin/ and /opt/bin/ - those should already be in your PATH. (Look inside these folders and if there are many files in them, then it is the wrong place to put your own program and you have to look at other folders listed in your PATH.)
  2. Modify your PATH variable. This is less secure, because it defines additional folders where programs can be kept and someone might play a trick on you, putting his own program there for you to run.

    You can modify the PATH variable either temporarily, using

    export PATH="$PATH:/path/to/your/executable"

    (mind the $PATH after =), or permanently by adding the above line to your .bashrc file (assuming you use bash).

share|improve this answer

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.