2. The Command Line¶
You've already used one command line in Unit 3 (Python Basics) — the Linux Terminal tile. Windows has two of its own, and they're not interchangeable.
Windows: CMD vs. PowerShell¶
CMD is the old command line, dating back to early Windows — still around for compatibility. PowerShell is newer, far more powerful, and the one worth learning: it works with structured objects, not just plain text, and can do almost anything the Windows GUI can.
The same basic actions, three ways¶
| Action | Linux/macOS (bash) | Windows CMD | Windows PowerShell |
|---|---|---|---|
| List files | ls |
dir |
Get-ChildItem (alias: ls) |
| Show current directory | pwd |
cd (no argument) |
Get-Location (alias: pwd) |
| Change directory | cd folder |
cd folder |
Set-Location folder (alias: cd) |
| View a file's contents | cat file.txt |
type file.txt |
Get-Content file.txt (alias: cat) |
| Copy a file | cp a b |
copy a b |
Copy-Item a b |
| Delete a file | rm file |
del file |
Remove-Item file |
PowerShell's aliases (ls, pwd, cat) exist specifically to feel familiar if you already know bash — worth knowing they're aliases for the real PowerShell commands, not separate things.
Try it
On the Windows Terminal tile, run Get-ChildItem, then run ls. Confirm they do the same thing, then explain why that's true using the idea of an alias.
Tip
PowerShell command names follow a consistent Verb-Noun pattern (Get-Content, Remove-Item, Set-Location) — once you know that pattern, you can often guess a command's name correctly before ever looking it up.
Play it
Open the Operating Systems Lab and use the Command line tab.