Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Command Prompt Explained: Useful Windows CMD Commands

Open CMD, navigate safely, run file, network, process, power, and system diagnostics, and recognize commands that can overwrite or delete data.

Table of Contents

Command Prompt is Windows' traditional command-line shell. It runs programs and built-in commands from typed instructions, which makes repeatable diagnostics and file tasks fast—but it also executes destructive commands immediately. Read the syntax and confirm the current folder before pressing Enter.

What is Command Prompt? CMD commands and code on Windows Picture 1

Open Command Prompt

  • Open Start, type Command Prompt, and select it.
  • Press Windows + R, enter cmd, and press Enter.
  • Open Windows Terminal and select a Command Prompt profile.

Use Run as administrator only when a trusted instruction genuinely requires elevation. An elevated prompt can change protected system areas.

Understand the prompt and help

The text before the cursor is the current directory. Paths containing spaces must be quoted, such as dir "C:Program Files". Use command /? for built-in help—for example, robocopy /?. Press Tab to complete filenames and the up arrow to recall previous commands.

What is Command Prompt? CMD commands and code on Windows Picture 2

Safe commands for orientation

CommandPurpose
cdShow or change the current directory
dirList files and folders
type file.txtDisplay a plain-text file
systeminfoShow Windows and hardware summary
tasklistList running processes
driverqueryList installed drivers
whoamiShow the current account context

Network diagnostics

CommandWhat it tells you
ipconfigAddresses for network adapters
ipconfig /allDetailed adapter, DHCP, DNS, and gateway data
ping example.comWhether echo replies arrive and their round-trip time; blocking replies does not prove a site is down
tracert example.comVisible hops toward a destination
pathping example.comLonger route and packet-loss sampling
netstat -anoConnections, listening ports, and process IDs
nslookup example.comDNS lookup results

ipconfig /release drops a DHCP address; do not use it merely to view the current IP. ipconfig /renew requests a new lease and can interrupt connectivity.

Processes and shutdown

taskkill /PID 1234 asks a process to stop. Add /F only when necessary because forcing an app can lose unsaved work. To restart immediately, use shutdown /r /t 0; to shut down, use shutdown /s /t 0. Cancel a delayed action with shutdown /a.

What is Command Prompt? CMD commands and code on Windows Picture 3

Compare and copy files

fc "file1.txt" "file2.txt" compares text files; fc /b performs a binary comparison. For robust folder copying, learn robocopy and test with a small folder. A copy command can overwrite existing data, so quote paths and verify source and destination.

System diagnostics

  • powercfg /batteryreport creates a battery report on supported laptops.
  • powercfg /energy performs an energy analysis and usually needs elevation.
  • sfc /scannow checks protected Windows files from an administrator prompt.
  • DISM.exe /Online /Cleanup-Image /RestoreHealth repairs the Windows component image before SFC when required.

Read the SFC and DISM guide before assuming every reported issue is fixed.

What is Command Prompt? CMD commands and code on Windows Picture 4

Commands that can destroy data

del, rd /s, format, diskpart, registry commands, permission changes, and forced process termination can remove files or break Windows. Command Prompt deletion bypasses the Recycle Bin. Never paste an unfamiliar command from a message or video, and never run an encoded or obfuscated command.

Command Prompt, PowerShell, and Terminal

Command Prompt interprets classic CMD syntax. PowerShell is a different shell with object-based commands and scripting. Windows Terminal is a host that can open either shell. Do not assume syntax copied for one works safely in another. For more navigation examples, see basic CMD commands.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.