Windows does not natively include the ls
command found in Unix-like systems. Follow these methods to use similar functionality.
Method 1: Using PowerShell
PowerShell aliases ls
to Get-ChildItem
by default:
- List files/folders in current directory:
ls
- Show detailed view:
ls Format-Table Name, Length, LastWriteTime
- List hidden items:
ls -Force
- Recursive listing:
ls -Recurse
Method 2: Using Command Prompt (CMD) Alternatives
Replace ls
with dir
in CMD:
- Basic directory listing:
dir
- Show wide list format:
dir /W
- Include hidden files:
dir /A
- Recursive list:
dir /S
Method 3: Installing Unix-like Tools
For native ls
behavior:
- Install Git for Windows:
Run
ls
in Git Bash terminal after installation - Enable WSL:
Install Windows Subsystem for Linux and usels
in Linux distributions - Use third-party ports:
CoreUtils (e.g., )
Common ls-like Flags Comparison
-l
→ PowerShell:ls Format-List
/ CMD:dir /Q
-a
→ PowerShell:ls -Force
/ CMD:dir /A
-t
→ PowerShell:ls Sort-Object LastWriteTime