Linux / UNIX: Command not found error and how do I get rid of it?

by Vivek Gite [Last updated: December 19, 2007]

Q. Why I am getting the error Command not found? How do I fix this problem?

A. A common question asked by new Linux or UNIX users. When you get the error "Command not found" it means that Linux or UNIX searched for command everywhere it knew to look and could not find a program by that name. Another cause is you misspelled the command name (typo) or administrator does not at all install the command on your Linux/UNIX system. To get rid of this error:

1) Make sure command was not misspelled:
All Linux and UNIX commands are case sensitive and you type correct spelling of command.

2) Make sure command is your path
You can see current search path with following command:

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/home/vivekgite/bin

Usually all user commands are in /bin and /usr/bin or /usr/local/bin directories. All your programs are installed in these directories. When you type clear command, you are running /usr/bin/clear. So if it is not in path try to add directories to your search path as follows (setup Linux or UNIX search path with following bash export command):

$ export PATH=$PATH:/bin:/usr/local/bin

You can also find out of path of any command with which or whereis commands:

$ which ls

/bin/ls

$ which gcc

/usr/bin/gcc

$ which date

/bin/date

$ which cal

/usr/bin/cal

$ whereis gcc

/usr/bin/gcc

Remember you can run a program using its full pathname:

$ /bin/ls
$ /bin/date

Finally, sometime you may not have permission to run the command.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 10 comments… read them below or add one }

1 Lei Zhu 10.02.06 at 3:13 am

Hi,I have a problem when I run the command under Cygwin.
I type
./run.bash
However,it shows:
:command not found
‘/run.bash: line 6: Syntax error near unexpected token ‘

‘/run.bash: line 6: ‘function gplot’

All this code was definitely right, that’s our teacher who give to us..
So what’s the problem?
Thank you

2 nixcraft 10.02.06 at 7:02 am

Line 6 has an error. Can you just copy and paste your source code here. Put in

<code>your script code…</code>

tags, so that I can help you further.

3 sanjay 08.20.07 at 7:17 pm

the command ’setup’ is not working, it says command not found although there is a man page for that command…can u help me how to make it work or is there any alternate command for the above??

4 sandeep 09.07.07 at 5:51 am

Hi
I have a bash script say “simulate”.
When i type simulate on cmd prompt, it says
command not found. but when i type
./simulate it works.
What can be reason. i checked PATH, /bin is there.
Which bash says /bin/bash.
regards
Sandeep

5 vivek 09.07.07 at 10:19 am

Sandeep,

Add your home directory to PATH
export PATH=$PATH:/home/you

6 ranjani 11.20.07 at 8:43 am

Hi configure command is not there in my bin folder. So this command is not executing. Pls help me that what i have to do to run this command?

7 CL23 12.23.07 at 1:07 am

If the $PATH variable is correct a fully qualified path works, try typing “rehash” at the command prompt to update the systems list of valid commands.

8 shan 08.20.08 at 6:04 pm

the man command is not working
it gives comand not found error.

9 jathin sanghvi 11.04.08 at 1:05 pm

i get an error as ‘Command not found’ when i use zgrep. can any one help me on this. any command to grep through zip files(i need the filename as output)

10 zaid 12.12.08 at 8:15 am

hi guys!

i’m new to ns2..could someone please tell me why i keep having “command not found” error messages as follows. What should i doooo??? HELP

zaid@ymax-hw-0006:~/Desktop/ns-allinone-2.32/ns-2.32$ testing.tcl
/home/zaid/Desktop/ns-allinone-2.32/ns-2.32/testing.tcl: line 4: namtrace-all: command not found
/home/zaid/Desktop/ns-allinone-2.32/ns-2.32/testing.tcl: line 6: proc: command not found
/home/zaid/Desktop/ns-allinone-2.32/ns-2.32/testing.tcl: line 7: global: command not found
/home/zaid/Desktop/ns-allinone-2.32/ns-2.32/testing.tcl: line 8: flush-trace: command not found
/home/zaid/Desktop/ns-allinone-2.32/ns-2.32/testing.tcl: line 9: close: command not found
zaid@ymax-hw-0006:~/Desktop/ns-allinone-2.32/ns-2.32$ Cannot connect to existing nam instance. Starting a new one…

nam: Unable to open the file “out.nam.nam”

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , ,

Previous post: Linux / UNIX find out what other users are doing?

Next post: Environment variable changing on Linux/FreeBSD