Why does `ls` work on my cmd? (Windows)

I'm running windows 7, it's old and I have messed around with it a bit. When I'm in cmd I find that ls works just like I would expect it to in Linux. So do a few other commands such as mv and rm. This isn't an issue in itself, but I would like to know where they are coming from. As far as I know Windows does not support these automatically. I probably added them myself at some point. Is there any way I can try and devise why they are working?


From cmd you can use the where command to find the location of an executable:

where ls

This is similar to the Unix which command, and like which it does not report internal commands and aliases. It also has additional options not in which.

If it's one of the Unix commands you have imported, you can use which itself.


You might have installed Git repository. This might be from your C:\Program Files\Git\usr\bin\ls.exe


https://superuser.com/questions/1248999#1581575

The original poster has already confirmed that the source in their case is
C:\Program Files (x86)\GnuWin32\bin\ls.exe.

But as suggested by Shanmugam, the reason unix commands run in the Windows command line, cmd, might be that you have GitBash installed.

If so, when ls runs from the command line, a likely source is
C:\Program Files\Git\usr\bin\ls.exe.

You might have installed GitBash from https://git-scm.com/download/win or https://gitforwindows.org/.

When installing GitBash, the path C:\Program Files\Git\usr\bin is not added by default to the PATH environment variable. So you may want to do this yourself, as follows.
Hit the win key on your keyboard, and then paste or type envi. Click on Edit the system environment variables. Click on the button down to the right named Environment Variables.... In the System variables frame, scroll down and double-click on PATH as in the figure below.

Environment Variables > System variables > PATH

A new window opens. Click on the New button and then paste or type
C:\Program Files\Git\usr\bin. Click yourself out (three times on OK).

Please note that you need to close and restart cmd.exe (the terminal window) for the changes to take effect.
The emulated Unix commands in C:\Program Files\Git\usr\bin should now work from anywhere in the command line.

Having read this far, chances are that you will want to consider installing Clink as well.