7

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?

1
  • Concerning the current tag [windows-7]. The 'windows' tag wiki says: "For questions not specific to a single version of Microsoft Windows. Otherwise, use a more specific tag such as [windows-7] or [windows-10].". Aug 29, 2020 at 15:08

3 Answers 3

10

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.

1
  • 1
    The response I get to this is C:\Program Files (x86)\GnuWin32\bin\ls.exe So I guess that's where stuff is coming from. Thanks
    – Clumsy cat
    Sep 10, 2017 at 9:11
5

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

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .