Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cygwin ls command not found [closed]

Tags:

path

ls

cygwin

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.

like image 509
Sudipta Chatterjee Avatar asked Feb 10 '13 11:02

Sudipta Chatterjee


People also ask

Why my ls command is not working?

Because LS is a Unix command and Windows' CMD is not a Unix shell like BASH. The DOS (and Windows) equivalent of LS is DIR /W . If you want LS to work natively in CMD, you'll need gow . Unlike MinGW, MSys and WSL[1], gow is incredibly lightweight.

How do I terminate Cygwin?

When you are done using Cygwin/X, you can shutdown the X server by: Selecting the "Exit..." option from the notification area icon menu. In Windowed mode: Press Alt-F4 to shutdown the X Server.

Is Cygwin still supported?

As of the creation of this article: Red Hat Cygwin is supported on all 32- and 64-bit versions of Windows since 2003 Server. Cygwin is available as both a 32- and 64-bit platform supporting 32 on 32-bit, 32 on 64-bit, and 64 on 64-bit installations.

Can I run Linux commands on Cygwin?

Cygwin is a collection of tools that provide a Linux Operating System's terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS.


Video Answer


2 Answers

  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.

like image 161
Sudipta Chatterjee Avatar answered Sep 22 '22 12:09

Sudipta Chatterjee


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)

like image 39
michael Avatar answered Sep 22 '22 12:09

michael