Windows - Cheatsheet
Windows Command Prompt (CMD) Cheatsheet: Commands You’ll Actually Use
A practical Windows CMD cheatsheet with real-world examples: navigation, files, networking, processes, redirection, and handy one-liners.

Windows Command Prompt (CMD) Cheatsheet
This quick-reference guide collects the most useful Windows Command Prompt commands with short explanations and copy-paste examples. If you live in PowerShell, most of these still help when you drop into cmd.exe
for legacy tools or build scripts.
Basics
Use these to get oriented and find help.
help :: list all available commands
help dir :: show help about the 'dir' command
cls :: clear the screen
exit :: close the Command Prompt window
Navigation & Files
Change folders, list contents, create and remove things.
dir :: list files and folders in current directory
cd C:\path\to\folder :: change directory
cd .. :: move one level up
mkdir logs :: create a new folder named 'logs'
rmdir emptyFolder :: remove an empty folder
rmdir /S /Q folderWithStuff :: remove folder and its contents (quiet mode)
copy file.txt D:\backup\ :: copy file to backup folder
xcopy src D:\dest /E /I /H :: copy folder with subfolders and hidden files
move app.log D:\logs\ :: move file to another folder
del /Q *.tmp :: delete all .tmp files (quiet mode)
ren report.txt report-2025.txt :: rename a file
Viewing & Searching Files
Find and compare file contents quickly.
type README.txt :: display contents of a text file
more README.txt :: show text one page at a time
find "ERROR" app.log :: search for "ERROR" in file
find /I "success" build.log :: search ignoring case
fc old.cfg new.cfg :: compare two files
System & Hardware Info
Display system details, CPU info, and disk usage.
systeminfo :: display system information
hostname :: show computer name
ver :: show Windows version
echo %USERNAME% :: show current user
echo %COMPUTERNAME% :: show computer name
wmic cpu get name :: show CPU model
wmic logicaldisk get name,description,freespace,size :: list disks with details
Processes
List running processes and terminate tasks.
tasklist :: list running processes
tasklist | more :: list processes one screen at a time
tasklist /FI "IMAGENAME eq node.exe" :: filter to only node.exe processes
taskkill /IM notepad.exe /F :: force kill notepad.exe
Networking
Check IP configuration, ping hosts, trace routes, and manage Wi-Fi profiles.
ipconfig :: show basic network info
ipconfig /all :: show detailed IP configuration
ping 8.8.8.8 :: test connection to Google DNS
tracert example.com :: trace route to a host
netstat -an | more :: show active connections and ports
nslookup example.com :: check DNS records for a domain
netsh wlan show profiles :: list saved Wi-Fi profiles
netsh wlan show profile name="YourSSID" key=clear :: show Wi-Fi password
Users & Permissions
Manage user accounts, add to administrator groups, and run commands as another user.
whoami :: show current user
whoami /groups :: show user group memberships
net user :: list all local users
net user NewUser StrongP@ss! /add :: create a new user
net localgroup administrators NewUser /add :: give user admin rights
runas /user:DOMAIN\AdminUser cmd :: run program as another user
Disks & System Utilities
Check disks, run system file checks, and perform shutdown/restart tasks.
chkdsk C: :: check disk for errors
sfc /scannow :: scan and repair system files
shutdown /s /f /t 0 :: shutdown immediately
shutdown /r /t 0 :: restart immediately
diskpart :: open disk partition manager
wmic logicaldisk get caption,volumename,filesystem :: list drives and file systems
Redirection, Pipes & Chaining
Combine commands, redirect output, and use conditional execution.
dir /B | find /I ".log" :: list only files and filter those with ".log"
(ipconfig & echo. & systeminfo) > diagnostics.txt :: run multiple commands and save output to file
ping 1.1.1.1 >nul && echo Online || echo Offline :: test connection and print Online/Offline
Handy One-Liners
Short automation snippets to save time.
for /R %f in (*.tmp) do @del /Q "%f" :: delete all .tmp files in folder and subfolders
for /D %d in (*) do @echo %d :: list all subdirectories
forfiles /S /M *.log /D -7 /C "cmd /c del /q @file" :: delete .log files older than 7 days
setx PATH "%PATH%;C:\tools\bin" :: permanently add folder to PATH
Batch Scripting Template
Structure a .bat script with variables, conditions, and error handling.
@echo off :: don’t echo each command
setlocal enabledelayedexpansion :: enable delayed variable expansion
set LOG=build.log :: define variable LOG
echo Building... > "%LOG%" :: log message
if errorlevel 1 goto :fail :: if error, jump to fail section
echo Done. :: success message
exit /b 0 :: exit with success code
:fail
echo Build failed! >> "%LOG%" :: log failure
exit /b 1 :: exit with error code
Tip: Prefer PowerShell for new automation, but CMD remains essential for legacy tools, CI steps, and vendor scripts.