Windows CMD Cheat Sheet
A quick reference for the Windows Command Prompt, file and folder commands, networking, disk and system tools, plus handy keyboard shortcuts.
A reference for the classic Windows Command Prompt (cmd.exe). Type
command /? for built-in help on any command.
Navigating & listing
| Command | What it does |
|---|---|
cd | Show the current directory |
cd \path\to\dir | Change directory (cd .. goes up) |
cd /d D:\ | Change directory and drive |
dir | List files (dir /a shows hidden) |
tree | Show the folder structure as a tree |
cls | Clear the screen |
Files & folders
| Command | What it does |
|---|---|
type FILE | Print a text file's contents |
copy SRC DEST | Copy a file |
xcopy SRC DEST /E /I | Copy folders recursively |
robocopy SRC DEST /MIR | Mirror a folder tree (/E plus /PURGE): deletes files and folders in DEST that no longer exist in SRC |
move SRC DEST | Move or rename |
del FILE | Delete a file (/S recursive, /Q quiet) |
md NAME / rd NAME | Make / remove a directory (rd needs it empty; rd /s deletes the whole tree) |
ren OLD NEW | Rename a file |
System & processes
| Command | What it does |
|---|---|
tasklist | List running processes |
taskkill /IM name.exe /F | Force-kill a process by name |
taskkill /PID 1234 /F | Force-kill by process ID |
systeminfo | Detailed OS and hardware info |
sfc /scannow | Scan and repair system files (needs an administrator Command Prompt) |
shutdown /r /t 0 | Restart now (/s = shut down) |
Disks & drives
| Command | What it does |
|---|---|
chkdsk C: | Check a drive and report its status (read-only, fixes nothing) |
chkdsk C: /f | Fix file-system errors; on the drive Windows is using, it offers to run at the next restart |
chkdsk C: /r | Also find bad sectors and recover readable data (includes /f, much slower) |
defrag C: /O | Optimize a drive the right way for its type (defragment a hard disk, retrim an SSD) |
DISM /Online /Cleanup-Image /RestoreHealth | Repair the Windows image, then run sfc /scannow again |
These need an administrator Command Prompt (right-click, Run as administrator).
Networking
| Command | What it does |
|---|---|
ipconfig /all | Show full network configuration |
ipconfig /flushdns | Clear the DNS resolver cache |
ping HOST | Test connectivity to a host |
tracert HOST | Trace the route packets take |
nslookup DOMAIN | Look up DNS records |
netstat -ano | Active connections with owning PID |
Pipes, redirection & chaining
| Syntax | What it does |
|---|---|
CMD > file | Redirect output to a file (>> appends) |
CMD1 | CMD2 | Pipe output into another command |
CMD1 && CMD2 | Run CMD2 only if CMD1 succeeds |
find "text" file | Search for text within a file |
set | Show / set environment variables |
Keyboard shortcuts
| Keys | What it does |
|---|---|
| Tab | Complete a file or folder name (Tab is the default completion key) |
| ↑ / ↓ | Recall the previous / next command |
| F7 | Pick from a list of this session’s commands |
| F8 | Cycle through earlier commands that start with what you’ve typed |
| Esc | Clear the current line |
| Ctrl+← / Ctrl+→ | Move the cursor one word back / forward |
| Ctrl+C | Cancel the running command |
For modern scripting, see the PowerShell cheat sheet.
What this does
A Windows CMD cheat sheet collects the most useful Command Prompt commands — files and folders, networking, disk and system tools, plus handy shortcuts.
How to use it
- Browse by section.
- Find the command you need.
- Copy it with one tap.
- Run it in Command Prompt.
Example
ipconfig /all shows every network adapter’s full configuration.
Last updated .
Frequently asked questions
How do I open the Command Prompt?
Press Win+R, type cmd, and press Enter. For commands that change the system, right-click Command Prompt in the Start menu and select "Run as administrator".
Should I use CMD or PowerShell?
CMD is simpler and great for quick, classic commands. PowerShell is far more powerful for scripting and object-based output, see our PowerShell cheat sheet.
How do I get help for a command?
Type the command followed by /? (for example, dir /?) to see its options and usage.
Related tools
Linux Command Cheat Sheet
The essential Linux terminal commands on one page, files and navigation, permissions, processes, networking, and package managers. A quick reference for the bash shell.
PowerShell Cheat Sheet
A reference for PowerShell 7 and Windows PowerShell 5.1, discovering cmdlets, the object pipeline, filtering and formatting, managing files, processes and services, plus variables and flow control.
macOS Terminal Cheat Sheet
A reference for the macOS Terminal, the Mac-only commands (open, pbcopy, mdfind), system and defaults tools, Homebrew, core Unix commands, and keyboard shortcuts.
IBM AS/400 (IBM i) Cheat Sheet
A reference for the IBM i (AS/400, OS/400) command line, the work-with commands, libraries and objects, spooled files and output queues, messages, and 5250 function-key shortcuts.