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'm trying to run a program from the command line, and I got a -bash: command: command not found error. What can I do to troubleshoot/fix the problem?

share|improve this question

migrated from stackoverflow.com Dec 20 '11 at 5:22

This question came from our site for professional and enthusiast programmers.

closed as not a real question by enzotib, Chris Down, Gilles, Michael Mrozek Dec 22 '11 at 23:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Asking because I'd like a really good canonical answer; I've been searching around and I haven't found one that covers the PATH, using which to find programs on your PATH, the possible need to download a program, and/or the ability to permanently add variables to your PATH. – Kevin Burke Dec 20 '11 at 3:20
What program are you trying to run? Can you tell us more? What exactly did you type into the command line? – Aaron McDaid Dec 20 '11 at 4:03
I know how to run things on the PATH. I'm more trying to get an answer that will cover all cases for beginning developers. I'm writing a quickstart and trying to write a question I can link to that will help beginning developers troubleshoot the problem, when they get a command not found error. – Kevin Burke Dec 20 '11 at 5:07
Can you answer my questions? I'll give an example of why I'm paranoid and curious for more details: You said "-bash: command: command not found". This implies that it failed to find a command called command, or maybe a command called -bash: command . I know this sounds crazy, but if you type "-bash: command" into bash, then you will get the error message you've have given us. So please, give us all the details we ask for without hesitation. – Aaron McDaid Dec 20 '11 at 5:14
The FAQ says: "You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page." If information about exactly what command you ran doesn't help answer the question then it's probably the wrong kind of question. – Keith Thompson Dec 20 '11 at 10:37

I've been searching around and I haven't found one that covers the PATH, using which to find programs on your PATH

If you man which, it should tell you what the command does. But you have the right idea that it looks for executables in your path. type is also similar.

the possible need to download a program

googling the program name + your linux distro usually reveals how to download the program or install it using the package manager

and/or the ability to permanently add variables to your PATH.

Lot's of ways of doing this, basically you add the directory you to be able to execute files in somewhere in your PATH variable. The closer to the front of the PATH, the sooner bash will find it (thus is you have the same command in 2 different directories in the PATH, the first one usually gets executed). You can add your additions in a number of places (see one of the results in that google search), /etc/profile, or .bash_profile or .bashrc in your home directory if you want it just to apply to you.

However, in the case of command, it is not a program (which is why which does not find it), nor is it an alias. It is a bash built-in.

share|improve this answer

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