The Directory Listing Command
The dir command is your eyes in the terminal. It reveals what's inside any folder—files, subdirectories, sizes, dates, and more. With the right flags, you can filter, sort, and customize the output exactly how you need it.
Usage:dir
[drive:][path]
[/a]
[/s]
[/o]
[/p]
/a
Displays files with specified attributes (hidden, directories, read-only, etc.).
/s
Lists files in the specified directory and all subdirectories.
/o
Sorts by order: n=name, e=extension, d=date, s=size.
/p
Pauses after each screen of information (useful for long lists).
/w
Uses wide list format (compact view).
*.ext
Wildcard to filter by file extension (e.g., *.txt).
Real-World Examples
Find all PDFs in your Documents folder:
Command Prompt
C:\Users\User>dir C:\Users\YourName\Documents\*.pdf /s
See hidden system files:
Command Prompt
C:\Users\User>dir /a
List files sorted by date (newest first):
Command Prompt
C:\Users\User>dir /o:-d
Knowledge Check
1 / 3Which command lists ALL files, even hidden ones?