69

This is a question that I self-answered on my tech blog where I keep the tech-tips which I need to give to myself from time to time, so I decided to move it over here instead. The original blog post is here: http://thehacklist.blogspot.com/2009/04/cygwin-ls-command-not-found.html

If you are a linux enthusiast and really miss those greps and sed/awks on the windows box, you've probably installed cygwin. You tried running it either by double-clicking the cygwin icon on your desktop or the cygwin.bat file in your C:\cygwin directory and got the bash-3.X$ prompt. However, although the pwd or cd commands work, if you try ls, it says:ls: command not found.

Zombo
  • 1
  • 55
  • 342
  • 375
Sudipta Chatterjee
  • 4,438
  • 1
  • 24
  • 30
  • 33
    Guys, why do you close cygwin related topics? If you are developer and never used it, it doesn't mean that other developers should not use it too. please do not close these topics. Thanks. – Kostanos Sep 08 '13 at 17:38
  • 4
    By the way, if you closed this one, you probably should close all other related cygwin topics: http://stackoverflow.com/questions/225764/safely-change-home-directory-in-cygwin for example. – Kostanos Sep 08 '13 at 17:49
  • 8
    Thank you for the post, this was really helpful to me. I think it's unfortunate it was closed. – AmericanUmlaut Mar 03 '14 at 19:09
  • 5
    closing such topic seriously... why you even have the cygwin tag then – Mubashar Sep 29 '15 at 05:14
  • Nice find! Do you know what caused this to happen though? I'm really curious, I have installed cygwin multiple times in all possible windows OS and this is the first time it happened to me in Windows 10 Version 1607 Build 14393.187. – laertis Sep 30 '16 at 07:27

2 Answers2

95
  1. Right click on "My Computer" -> Properties -> Advanced -> Environment Variables
  2. Add a new environment variable, called CYGWIN_HOME and set its value to C:\cygwin
  3. Edit the PATH environment variable and add %CYGWIN_HOME%\bin to it (usually separated by a ';').
  4. Just click okay, exit any command prompts or bash shells (over cygwin) you may have open, and open it again - it'll work!

Assumption - this assumes that you have installed cygwin at C:\cygwin. If you've kept it someplace else, please modify the above accordingly.

Sudipta Chatterjee
  • 4,438
  • 1
  • 24
  • 30
15

Check the cygwin.bat file, it should have something like:

set PATH=C:\cygwin\bin;C:\cygwin;%PATH%
...etc
bash --login -i

(you don't really need c:\cygwin in there, but I have some additional scripts/bat files there; the key thing is c:\cygwin\bin)

michael
  • 7,805
  • 2
  • 45
  • 48