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
- Open the right shell. Press
Win + R, typecmdand press Enter to open Command Prompt. For PowerShell, pressWin + Xand choose Windows PowerShell or Terminal from the menu. Menu labels can differ slightly by Windows version and region. - Navigate to the folder you want to list. Use
cdfollowed by the path, for examplecd C:\Users\YourName\Documents. In Command Prompt you can also typecd /d D:\Projectsto switch drives. In PowerShell,cdworks the same way and accepts quoted paths with spaces:cd "C:\My Folder". - Run the basic listing. In Command Prompt, type
dirand press Enter. In PowerShell, typels(orGet-ChildItem) and press Enter. Both show files and folders in the current directory. - Read the output. Command Prompt's
dirdisplays the date and time, a<DIR>marker for folders, the file size in bytes, and the file name. PowerShell'slsshows Mode, LastWriteTime, Length (size), and Name. Folders appear without a Length value in PowerShell. - 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. - Show hidden and system files. Command Prompt:
dir /aincludes hidden and system items. PowerShell:ls -Forcedoes the same. Use this only when you need to see protected files; avoid deleting them. - Get a bare list of names. Command Prompt:
dir /bprints only file and folder names, one per line. PowerShell:ls -Namegives the same clean output. This is useful for scripting or copying into a text file. - Filter by pattern. Command Prompt:
dir *.txtlists only text files. PowerShell:ls *.txtworks identically. You can combine with/sin Command Prompt (dir /s *.log) or-Recursein PowerShell (ls -Recurse *.log) to search subfolders. - Sort the results. Command Prompt:
dir /o:nsorts by name,/o:sby size,/o:dby date. PowerShell: pipe toSort-Object, for examplels | Sort-Object Length. - Page through long output. Command Prompt:
dir /ppauses after each screen. PowerShell:ls | Out-Host -Pagingor pipe tomore(ls | more). - Save the listing to a file. Command Prompt:
dir > listing.txtwrites the output to a text file in the current folder. PowerShell:ls | Out-File listing.txt. Check the file withtype listing.txt(Command Prompt) orGet-Content listing.txt(PowerShell). - Use
lsin PowerShell as an alias. PowerShell defineslsas a built-in alias forGet-ChildItem, so typinglsworks out of the box. If you wantlsin Command Prompt, you would need to create a batch file or doskey macro — but that is not recommended because it can confuse scripts. Stick withdirin Command Prompt.
Common Mistakes
- Typing
lsin Command Prompt. It returns “'ls' is not recognized as an internal or external command.” Usedirinstead, or switch to PowerShell. - Forgetting to change drives. In Command Prompt,
cd D:\Folderdoes not switch to D: unless you add/d. Usecd /d D:\Folderor typeD: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 -lworks everywhere. PowerShell aliases accept some Unix-style parameters, but not all. UseGet-ChildItemwith its own parameters (e.g.,-Force,-Name) for reliable results. - Ignoring hidden files. By default, both
dirandlshide system and hidden items. If a file seems missing, add/aor-Forcebefore 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,
lsreturns objects, not just text. You can pipe toWhere-Objectto 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
lsnatively in PowerShell tabs. - For a graphical alternative, File Explorer shows the same information; press
Alt + Dto 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 /wfor a wide list in Command Prompt. - Command not found in PowerShell. Ensure you are in PowerShell, not Command Prompt. If
lsstill fails, typeGet-ChildItemdirectly — 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 + Cto 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.