Windows has no built-in ls command, but you can get identical results with dir in Command Prompt or Get-ChildItem in PowerShell. The quickest route is to open Command Prompt and type dir; if you prefer the familiar ls spelling, install Windows Terminal with PowerShell and use ls as an alias for Get-ChildItem. This guide covers both methods, plus how to read the output and avoid common pitfalls.

What You'll Need

  • A Windows 10 or Windows 11 PC (the steps also work on Windows 8.1 with minor menu differences).
  • Access to Command Prompt or PowerShell — both are preinstalled, no download required.
  • Basic familiarity with typing commands and pressing Enter.
  • Optional: Windows Terminal (free from the Microsoft Store) for a tabbed, modern console that supports both shells.

Step-by-Step

  1. Open the right shell. Press Win + R, type cmd and press Enter to open Command Prompt. For PowerShell, press Win + X and choose Windows PowerShell or Terminal from the menu. Menu labels can differ slightly by Windows version and region.
  2. Navigate to the folder you want to list. Use cd followed by the path, for example cd C:\Users\YourName\Documents. In Command Prompt you can also type cd /d D:\Projects to switch drives. In PowerShell, cd works the same way and accepts quoted paths with spaces: cd "C:\My Folder".
  3. Run the basic listing. In Command Prompt, type dir and press Enter. In PowerShell, type ls (or Get-ChildItem) and press Enter. Both show files and folders in the current directory.
  4. Read the output. Command Prompt's dir displays the date and time, a <DIR> marker for folders, the file size in bytes, and the file name. PowerShell's ls shows Mode, LastWriteTime, Length (size), and Name. Folders appear without a Length value in PowerShell.
  5. List a different folder without changing directory. In Command Prompt: dir C:\Windows. In PowerShell: ls C:\Windows. This is handy for a quick peek without losing your place.
  6. Show hidden and system files. Command Prompt: dir /a includes hidden and system items. PowerShell: ls -Force does the same. Use this only when you need to see protected files; avoid deleting them.
  7. Get a bare list of names. Command Prompt: dir /b prints only file and folder names, one per line. PowerShell: ls -Name gives the same clean output. This is useful for scripting or copying into a text file.
  8. Filter by pattern. Command Prompt: dir *.txt lists only text files. PowerShell: ls *.txt works identically. You can combine with /s in Command Prompt (dir /s *.log) or -Recurse in PowerShell (ls -Recurse *.log) to search subfolders.
  9. Sort the results. Command Prompt: dir /o:n sorts by name, /o:s by size, /o:d by date. PowerShell: pipe to Sort-Object, for example ls | Sort-Object Length.
  10. Page through long output. Command Prompt: dir /p pauses after each screen. PowerShell: ls | Out-Host -Paging or pipe to more (ls | more).
  11. Save the listing to a file. Command Prompt: dir > listing.txt writes the output to a text file in the current folder. PowerShell: ls | Out-File listing.txt. Check the file with type listing.txt (Command Prompt) or Get-Content listing.txt (PowerShell).
  12. Use ls in PowerShell as an alias. PowerShell defines ls as a built-in alias for Get-ChildItem, so typing ls works out of the box. If you want ls in Command Prompt, you would need to create a batch file or doskey macro — but that is not recommended because it can confuse scripts. Stick with dir in Command Prompt.

Common Mistakes

  • Typing ls in Command Prompt. It returns “'ls' is not recognized as an internal or external command.” Use dir instead, or switch to PowerShell.
  • Forgetting to change drives. In Command Prompt, cd D:\Folder does not switch to D: unless you add /d. Use cd /d D:\Folder or type D: first.
  • Paths with spaces. Always wrap paths in double quotes: cd "C:\Program Files". Without quotes, the shell treats the space as a separator.
  • Assuming ls -l works everywhere. PowerShell aliases accept some Unix-style parameters, but not all. Use Get-ChildItem with its own parameters (e.g., -Force, -Name) for reliable results.
  • Ignoring hidden files. By default, both dir and ls hide system and hidden items. If a file seems missing, add /a or -Force before concluding it is gone.

Tips

  • Use Tab completion: type part of a folder name and press Tab to auto-complete the path in both Command Prompt and PowerShell.
  • Press the Up arrow to recall previous commands — handy for repeating a listing with a tweak.
  • In PowerShell, ls returns objects, not just text. You can pipe to Where-Object to filter by size or date, e.g., ls | Where-Object Length -gt 1MB.
  • Windows Terminal lets you open multiple tabs (Command Prompt, PowerShell, WSL) and supports ls natively in PowerShell tabs.
  • For a graphical alternative, File Explorer shows the same information; press Alt + D to focus the address bar and type a path.

Troubleshooting

  • “Access is denied” when listing a folder. You lack permissions. Run the shell as administrator (right-click Command Prompt or PowerShell and choose Run as administrator) or choose a folder you own.
  • Output is garbled or too wide. The console window may be too narrow. Widen it by dragging the edge, or use dir /w for a wide list in Command Prompt.
  • Command not found in PowerShell. Ensure you are in PowerShell, not Command Prompt. If ls still fails, type Get-ChildItem directly — the alias may have been removed by a custom profile.
  • Listing seems to hang on a network drive. The drive may be slow or disconnected. Press Ctrl + C to cancel, then check the drive in File Explorer.
  • Saved file is empty. The redirection may have failed due to permissions. Try saving to your Documents folder: dir > %USERPROFILE%\Documents\listing.txt.

Frequently Asked Questions

Is there a real ls command in Windows?

No. Windows Command Prompt uses dir. PowerShell provides ls as an alias for Get-ChildItem, so it works there.

Can I use ls in Command Prompt?

Not by default. You would need to create a batch file or macro, but that is not recommended. Use dir or switch to PowerShell.

How do I list files recursively?

In Command Prompt: dir /s. In PowerShell: ls -Recurse. Add a pattern like *.txt to narrow results.

Why does ls show different columns than dir?

PowerShell outputs objects with properties like Mode and Length, while dir prints formatted text. Both list the same items.

How do I see hidden files?

Use dir /a in Command Prompt or ls -Force in PowerShell. Hidden system files will then appear.

Can I use ls in Windows Subsystem for Linux (WSL)?

Yes, WSL provides a full Linux environment where ls works as expected. Open your WSL distribution from the Start menu.