How to Use the “ls” Command Equivalent on Windows

The ls command, short for “list,” is a Linux command that’s used to display files and directories in the terminal. In most cases, it is used to get an idea about the files in the working directory and to ensure you are in the right directory. When you compare this to a rival operating system, the Command Prompt in Windows has a different approach when it comes to listing directories. In this guide, we will explain how to use the “ls” command on Windows 10 and 11.

What is the “ls” Command Equivalent on Windows?

The ls command from Linux is not supported in Command Prompt on Windows, and you will get the following error when you try to run this command: ‘ls’ is not recognized as an internal or external command, operable program, or batch file.

However, we have an alternative that does work in the Command Prompt. The ls command equivalent on Windows is “dir,” which is short for directory. The dir command is supported in the command prompt on Windows 10 and 11, but Powershell lets you use the ls command to list directories and files. The method of getting into a directory remains the same, i.e., by using the command “cd <dir name>” (change directory) command.

How to Use the “ls” Command in Command Prompt

Here’s how to use the command that brings the “ls” functionality in the Command Prompt on Windows:

1. Go to the Start menu, search CMD, and launch Command Prompt.

launch cmd

2. Then, use the cd command to move to the directory you want to see the contents of. For example, we switched to the Desktop.

cd Desktop

Notably, you can also move backward into directories using the command “cd ../”

3. Finally, type “dir” and hit Enter to see all files and folders in the current working directory.

How to Use the “ls” in Windows PowerShell

Unlike Command Prompt, Windows PowerShell recognizes the “ls” command, just like Linux, and lists all files and folders in the working directory. Here’s how to use the “ls” command in Windows PowerShell.

1. Go to Start and search for Windows PowerShell. Click to open the window.

2. Move into a directory using the cd command and use the command “ls” to see its contents.

3. You can also use the “dir” command to list directories in Windows PowerShell.

Difference Between Command Prompt and PowerShell

Both Command Prompt and PowerShell are terminals used to execute batch files, but Windows PowerShell is more modern and powerful compared to Command Prompt. It’s used to automate tasks, execute files and programs, and more importantly, pipe information from one application to another, just like Bash on Linux. That said, which of these do you use most often — Command Prompt or PowerShell? Let us know in the comments section below.

Comments 0
Leave a Reply