'ls' is not recognized as an internal or external command, operable program or batch file
Asked Answered
P

10

67

'ls' is not recognized as an internal or external command, operable program or batch file. I get this error when I try to glance at the files of my folder.

  • cmd opened regularly(not as an admin).
  • I've recently downloaded anaconda for python.During the installation process, there was a time when I allowed to add a PATH which was not recommended. 'ls' used to work well be

    Here are the paths

    enter image description here

Philosophism answered 28/2, 2018 at 15:4 Comment(5)
Are you sure you are not supposed to be using 'dir' since it is windows?Grantland
You can use it in other terminal programs like GitBash but it is not shipped with windows.Grantland
dir on windows is similar to ls. Do dir/? for various options. You could also install 3rd party tools to allow you to run unix commands on windows. Try cygwinOxazine
ls also might work on some ftp servers if they have a linux based back. That ftp being used from cmdBrandish
You can install the Microsoft Windows Subsystem for Linux. learn.microsoft.com/en-us/windows/wsl/install-win10Cotterell
A
126

I'm fairly certain that the ls command is for Linux, not Windows (I'm assuming you're using Windows as you referred to cmd, which is the command line for the Windows OS).

You should use dir instead, which is the Windows equivalent of ls.

Edit (since this post seems to be getting so many views :) ):

You can't use ls on cmd as it's not shipped with Windows, but you can use it on other terminal programs (such as GitBash). Note, ls might work on some FTP servers if the servers are linux based and the FTP is being used from cmd.

dir on Windows is similar to ls. To find out the various options available, just do dir/?.

If you really want to use ls, you could install 3rd party tools to allow you to run unix commands on Windows. Such a program is Microsoft Windows Subsystem for Linux (link to docs).

Affine answered 28/2, 2018 at 15:11 Comment(3)
You can use ls in powershellTatum
@Tatum sickAffine
use "dir/adh" command to see the hidden files tooAnt
C
45

We can use ls and many other Linux commands in Windows cmd. Just follow these steps.

Steps:

1) Install Git in your computer - https://git-scm.com/downloads.

2) After installing Git, go to the folder in which Git is installed. Mostly it will be in C drive and then Program Files Folder.

3) In Program Files folder, you will find the folder named Git, find the bin folder which is inside usr folder in the Git folder.

In my case, the location for bin folder was - C:\Program Files\Git\usr\bin

4) Add this location (C:\Program Files\Git\usr\bin) in path variable, in system environment variables.

5) You are done. Restart cmd and try to run ls and other Linux commands.

Cryotherapy answered 17/1, 2019 at 13:43 Comment(0)
C
4

you can use dir instead of ls in cmd enter image description here

Chastitychasuble answered 4/11, 2021 at 17:32 Comment(0)
P
1

If you want to use Unix shell commands on Windows, you can use Windows Powershell, which includes both Windows and Unix commands as aliases. You can find more info on it in the documentation.

PowerShell supports aliases to refer to commands by alternate names. Aliasing allows users with experience in other shells to use common command names that they already know for similar operations in PowerShell.

The PowerShell equivalents may not produce identical results. However, the results are close enough that users can do work without knowing the PowerShell command name.

Phototopography answered 23/1, 2020 at 18:18 Comment(1)
This is right. I tried Powershell and ls command works in it. But it is not recognized in command prompt.Flatcar
S
1

when you use windows as operating system you should write dir and you will find all folders including empty folders and their data bytes storage

and you can use git ls-files to show all folders but not including hidden folders

Secunda answered 12/5, 2021 at 22:22 Comment(0)
F
1

for windows use "ls" command in windows powershell, and if you are in command prompt the use "dir" command instead of "ls" it is almost equivalent

Fleetwood answered 14/3, 2024 at 8:15 Comment(1)
For inline code usages you can use code syntaxis. For blocks of code you can use expanded code syntaxis like below ``` example of code ``` If you want to target the specific language, it's also possible php $var = 1; It's more visible in answersHodge
F
0

The reason you cannot run the ls command is because it does not exist on windows. The windows equivalent is the dir command, however it does not work the same way. The solution, Winls. It is

The ls command, written for windows.

According the the Winls github.

Fandango answered 27/12, 2021 at 20:40 Comment(0)
F
0

Had this error because i was using command prompt to access my files.

how did i solve it...

i opened my folder with vscode, and used bash from the terminal...the "ls" command worked as it should from bash.

Fatidic answered 17/1, 2023 at 14:49 Comment(0)
S
0

The ls command is a Unix/Linux command that is not recognized by Windows Command Prompt. Instead, you can use the dir command in Command Prompt to list the files and directories in the current directory.

Sheepskin answered 25/2, 2023 at 18:43 Comment(0)
M
0

you can use dir instead of ls to see all the files and folders present and use dir /a instead of ls -a to see all the hidden folders.

Multifoliate answered 17/6, 2023 at 9:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.