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?
1 Answer
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.
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.command not found
error.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.