Cheat Sheet Library

Windows Command Prompt Cheat Sheet

The classic Windows shell. Commands are not case-sensitive. Add /? to any command for help (for example dir /?).

  • 69 entries
  • 9 sections
  • Updated
  • Reviewed
  • Click a command to see all its options

69 entries

On this page
CommandAction

Files & Folders #

CommandAction
or Create a folder (creates parent folders as well)
Delete a folder and everything in it
Copy a file
Copy a folder with its subfolders
Robust copy (resumes, retries; best for large copies)
Mirror (deletes extra files in dst, so be careful)
Move a file
Rename
Delete a file
Delete matching files in all subfolders
Print a file
Print a file page by page
Write to a file (overwrites)
Hide a file (-h to unhide)
CommandAction
Find where a program is located
Search text in files (recursive, ignore case)
Count lines containing the text
Filter command output

System & Processes #

CommandAction
OS, RAM, install date, hotfixes
/ Computer name / current user
Running processes
Kill a process by name
Kill a process by PID
Shut down now
Restart now
Abort a scheduled shutdown
Repair system files (admin)
Check the disk for errors (admin)
Install software with the Windows package manager
Update all installed software

Network #

CommandAction
IP addresses
Full details (MAC, DNS, DHCP)
Clear the DNS cache
+ /renewGet a new IP from DHCP
Test connection (-t = keep pinging until stopped)
Show the route to a host
DNS lookup
Open ports with their process IDs
HTTP request (built in on Windows 10+)

Environment Variables #

CommandAction
List all variables
Print a variable
Set for this session only
setx NAME "value"Set permanently (takes effect in new windows)

Redirection & Chaining #

SyntaxMeaning
cmd > fileSend output to a file (overwrite)
cmd >> fileAppend to a file
cmd 2> err.txtSend errors to a file
cmd > out.txt 2>&1Send output and errors to the same file
cmd > nulDiscard output
a | bPipe output of a into b
a && bRun b only if a succeeds
a || bRun b only if a fails
a & bRun both, always

Keyboard #

KeyAction
TabAutocomplete file or folder name
↑ / ↓Previous / next command
F7Command history popup
EscClear the current line
Ctrl + CStop the running command

Tips #

  • Type cmd in the File Explorer address bar to open a prompt in that folder.
  • start . opens the current folder in Explorer. start https://site opens a URL.
  • Run as administrator: Win + X → Terminal (Admin), or right-click → Run as administrator.