Introduction to the Windows command line
Windows gives you more than one way to work at the command line. The two names you are most likely to meet are Command Prompt and PowerShell.
Command Prompt
Command Prompt, commonly opened as cmd, is the traditional Windows command interpreter. It is still useful, particularly because a lot of older instructions and development tools refer to it.
PowerShell
PowerShell is a much more capable shell and scripting environment. You do not need to become a PowerShell expert before you can use it to run Python, Git or other developer tools.
Some useful Command Prompt commands
dir: list files and directories.cd folder: move into a directory.cd ..: move up one directory.mkdir name: create a directory.copy: copy files.move: move files.del: delete files. Be careful; computers are remarkably obedient.cls: clear the screen.help: show help for built-in commands.
Paths with spaces
If a path contains spaces, put it in quotes:
cd "C:\Users\Bob Smith\Documents"
Running Python
Depending on your installation, commands such as python, py and python -m pip may be useful. If Windows cannot find Python, read our PATH guide.
Command Prompt or PowerShell?
Use whichever the instructions for your tool support and whichever you are comfortable with. For new Windows automation, PowerShell is generally the more capable choice. For simply changing folder and launching a program, either can do the job.
Spaces in paths
Sooner or later you will have a folder with a space in its name. Windows is quite fond of these.
If a path contains spaces, put it in quotes:
cd "C:\Program Files"
Without the quotes, a command may decide that C:\Program and Files are two separate things. Computers are wonderfully literal like that.
Command Prompt or PowerShell?
For basic jobs such as changing folders and launching Python, either can be perfectly fine. PowerShell is much more capable as a scripting environment, while Command Prompt is older and still appears in plenty of instructions.
The important thing for a beginner is to notice which shell a tutorial is using. A command copied from Bash on Linux will not necessarily work in Command Prompt, and a PowerShell command may not work in Command Prompt either.
Running something from the current folder
PowerShell has one little surprise worth knowing about. If an executable is in your current directory, you will commonly run it with .\ in front:
.\myprogram.exe
That .\ basically means "from here". We'll meet the same general idea when we talk about paths elsewhere.
Have a go
Create a folder somewhere safe, move into it from the command line, create another folder inside it, list the contents and then move back out again. Nothing dramatic needs to happen. The point is simply to get comfortable moving around without the mouse.
Further reading and external resources
Want to dig into this a bit more? These are good places to go next. If anything here ever disagrees with the official documentation, trust the official documentation.
Previous: Introduction to the command line | Next: Introduction to the Linux command line
Image Description