Thursday, April 9, 2009

Cygwin ls command not found

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".

Here is what you need to do to fix it:
  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 C:\cygwin\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!
Note: this assumes that you have installed cygwin at C:\cygwin. If you've kept it someplace else, please modify the above accordingly.

43 comments:

  1. Thanks, roger! Our first comment on the blog! :)

    ReplyDelete
    Replies
    1. Hi There !! My Cygwin still doesn't work....
      I am trying to use glx rendering
      i write this

      User@User-PC /cygdrive/d
      $ glxinfo | grep render
      and output is this
      bash: glxinfo: command not found
      NOTE : i am new to unix and cygwin/..Just need help

      Delete
  2. thanks sudipta! this was very helpful

    ReplyDelete
  3. Thank you so much. That is very help.

    ReplyDelete
  4. Thanks a lot! I spent so much time downloading
    Cygwin in order to learn Linux console
    commands - and it didn't know even about ls!

    I've translated your tip into Russian and
    posted to my blog. Hope, you don't mind

    ReplyDelete
  5. is it work when cygwin installation is not completed because i need ls command for installation purpose??
    there is no files in my bin folder .what should i do??

    ReplyDelete
  6. thanks buddy,
    what abt the wget command. it is also not working in my cygwin

    ReplyDelete
  7. hi there!

    But should you unistall the "run" package from Cygwin...

    Even though the Env. variable in Windows reads sequential and if we keep the Cygwin path the last - still may cause prob?


    Cheers!

    ReplyDelete
  8. As a side note, you may also want to add:

    C:\cygwin\usr\sbin to the PATH variable

    ReplyDelete
  9. For me , it only worked when i added C:\cygwin\usr\sbin also to the path..Thanks Sudipta

    ReplyDelete
  10. Dude, you friggin rock. THANKS.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Nice.Easy to deploy and understand.Thanks a lot dude

    ReplyDelete
  13. this is the most helpful thing i've ever found on the internet

    ReplyDelete
  14. It doesn't work for me! and I really wonder why since it seems to work for everybody else who commented!

    ReplyDelete
  15. exactly the info I needed, thank you so much!

    ReplyDelete
  16. bhayio top command bi kam ni kar ri meri to :)

    ReplyDelete
  17. it doesnt work with mine ..i am running win 7 ,,,,any idea how to get ride of it ???? help me plz. my samsung galaxy ace gts 5830 has bricked while flashing,,,not powering on but detects in odin,,?????

    ReplyDelete
  18. Thanks for blogging about useful commands.
    Ls command basically displays the content of directory in sorted alphabetically.
    If you have millions of files/directories, ls command hangs because of sorting.
    Ls –U ouput files without sorting and more useful
    Please see more about Ls command examples in Linux/Unix

    ReplyDelete
  19. Hi There !! My Cygwin still doesn't work....
    I am trying to use glx rendering
    i write this

    User@User-PC /cygdrive/d
    $ glxinfo | grep render
    and output is this
    bash: glxinfo: command not found
    NOTE : i am new to unix and cygwin/..Just need help

    ReplyDelete
  20. oh oh...
    doesn't work
    im on windows 7
    did exactly as you wrote
    :(

    ReplyDelete
  21. hi,
    can we add extra commands to existing command?
    if yes. how?

    ReplyDelete
  22. Thanks. Saved my bacon. Happens every 2 years.

    ReplyDelete
  23. Not working.... Any other proposals ?

    ReplyDelete
  24. It works! thanks for sharing good info.

    ReplyDelete
  25. I am working with cygwin emulator in windows 7 few commands are not working like MAN CAL And few plzz make solution to this problem

    ReplyDelete
  26. I have windows 10 an tried that approach, but it still didn't work.
    whyyyy :(

    ReplyDelete