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

by Vivek Gite on January 17, 2006 · 35 comments

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.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 35 comments… read them below or add one }

1 Lei Zhu October 2, 2006

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

Reply

2 nixcraft October 2, 2006

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.

Reply

3 sanjay August 20, 2007

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??

Reply

4 sandeep September 7, 2007

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

Reply

5 vivek September 7, 2007

Sandeep,

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

Reply

6 Hiroshi November 23, 2010

Thank you so much!

I was having this same problem.

Reply

7 ranjani November 20, 2007

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?

Reply

8 CL23 December 23, 2007

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.

Reply

9 shan August 20, 2008

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

Reply

10 jathin sanghvi November 4, 2008

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)

Reply

11 zaid December 12, 2008

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”

Reply

12 Jonas August 19, 2009

Help me
I have a samba server configuration , and when I will start it, it show me this post of error
/bin/bash: smbd: command not found
And I don´t know what i have to do for fix it

Reply

13 swarnima October 10, 2009

hi
when i used the echo command
its showing command not found
and i dnt know how to fix
plz help me

Reply

14 Didi October 11, 2009

my Linux Fedora 6 was hacked by some one who change the rights of root and give himself all right
now i can enter with root but when i want to execute command always get this message ‘commang not found’
what can i do to take back my root right please?

Reply

15 Zeeshan November 16, 2009

This is very very easy and useful. *** V V Good ***

Reply

16 swapna November 18, 2009

Hi,

I want to execute sas program through unix script.
I tried to execute simple program through script.below is the script:
#/bin/ksh
cd //SASDATA/cz/cp151/Macros
sas a.sas

However, I could not execute it.I get following message:
sh test.sh
test.sh: sas: not found

Please guide me .

Reply

17 RAJU A February 10, 2010

Dear friendz,
When i open terminal in ubuntu linx,it showing me::::; desktop:command not found

Reply

18 gejuboy April 18, 2010

I have installed successfull the ns2 .Tclscripts can’t be compiled,morover,uptil now(because i have just tried very simple & small programes) “puts” command is not working.It is saying- command not found.I have installed cygwin in g drive.I am opening the prompt from desktop shortkut & entering the directory by-
$ cd c:
$ cd cygwin
$ set a “5″
$ puts a
bash: puts: command not found
also i was trying to find whereis “puts command” i found the location but i dont know how to handle the problem .
puts: usr/share/man/man3/puts.3.gz

Thanks in advance……….

Reply

19 Sameer April 19, 2010

Hi Vivek,

I want to know the path for command “export”, command “set”
when I am doing
[root@test usr]# /usr/bin/which export
/usr/bin/which: no export in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin)

can you please help me on this?

Cheers,
Sameer

Reply

20 Justin May 6, 2010

Hi,
I ran into a “make: arm_v5t_le-gcc: command not found” with “make” facility while I was doing compile a program.
I ran this compiling with arm_v5t_le-gcc full path, I got the same error.
I checked the $PATH, and the the arm_v5t_le-gcc is in there.
I checked with “locate”, and the arm_v5t_le-gcc is there.
I checked with “which”, and the arm_v5t_le-gcc is there.
I checked the permission, and the arm_v5t_le-gcc is 755.
What else may cause this “command not found” error? Any guys can help me?
Thank you very much!
Cheer,
Justin

Reply

21 gherson May 24, 2010

which is in Base and Utils but whereis I can’t find in Cygwin

Reply

22 a September 2, 2010

thx mate,
I had terrible bugs because I named a variable PATH

find … | while read
PATH=subtr.

Reply

23 praveen October 31, 2010

thanks
export PATH……………
worked

Reply

24 chamberlain 7th January 25, 2011

it worked! thanks! very useful

Reply

25 ambitious February 16, 2011

hey there I am using backtrack4 in windows 7 my graphics card is atı hd 5650
when ı command this :
airodump-ng -w captura -c 11 — bssid 00:3e:d7:65:e2:87 wlan0
I GET ALLWAYS SAME ERROR
bash: 3e: command not found

note :I can see all of wifi/wlan etc.

Reply

26 kaosmonk February 24, 2011

do you happen to know where to look for that specific message “command not found” in centos? I’d like to chnage it to something else but am not able to locate it anywhere… have found it in other distros like ubuntu/debian – they have it in /etc/bash.bashrc and they even have such package by name command-not-found… and I was able to replace it with desired content… so, is there a way to perform the same on centos?

Reply

27 chat March 7, 2011

oldmodes is the users: command not found

Reply

28 Deswal April 8, 2011

I am using cygwin and when i compile program hello.cc
by command gcc hello.cc -o hello
it shows installation problem,cannot exec ‘cc’plus’:No such file or directory

but when i execute program with command ./hello.exe
it shows output

how should i remove this problem plz tell me.

Reply

29 amir May 17, 2011

Hi . I am using Red hat E 4 and i am working bops simulator.
after compile makefile , bops exe is producted and existed.
but by input command :bops test
Error is : bops :not command found.
thanks.

Reply

30 Radhika July 14, 2011

hi, I have installed ns2 simulator in fedora5.The installation happened perfectly,
but when i start opening ns,I am geeting error as command not found
$ns
$nam
error :command not found
please help me if i need to set any variables

Reply

31 ramani July 15, 2011

i dont get vi editor screen.whan i type “vi file name” i get the answer as command not found.i will be in /bin/bash. how did i over this problem.

Reply

32 Vadim September 1, 2011

Thank you so much!!

Reply

33 sandeep September 16, 2011

while using proc command in cygwin its displaying
bash:proc -command not found

can you please help me on this?

Reply

34 Justin October 1, 2011

Hi,
I just found this thread through Google.

My situation was similar, but the resolution was simple and different. It wasn’t related to the code at all.
I was on my Windows 7 machine connecting to my UNIX server through Notepad++ using the FTP plugin.

I was getting the same error mentioned here –
} ./test_script.sh
./test_script.sh: Command not found.

After looking at the initial things I was like “Doh!” and I checked the Notepad++ -> Edit Menu -> EOL Converstion settings and of course it was set to Windows and not UNIX.

After I set it to UNIX and uploaded the latest copy, the program executed without problems.

Just thought I’d note that here in case people have the same issue.

Peace,
Justin

Reply

35 Deepak November 9, 2011

hi, I have installed ns2 simulator in fedora5.The installation happened perfectly,
but when i start opening ns,I am geeting error as command not found
$ns
$nam
error :command not found
please help me if i need to set any variables

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 14 + 10 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: