0

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?

6
  • 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. Dec 20, 2011 at 3:20
  • 3
    What program are you trying to run? Can you tell us more? What exactly did you type into the command line? Dec 20, 2011 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. Dec 20, 2011 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. Dec 20, 2011 at 5:14
  • 2
    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. Dec 20, 2011 at 10:37

1 Answer 1

2

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.

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