Essential Windows CMD Commands: A Curated Reference
This guide compiles over 100 of the most useful Windows Command Prompt commands, organized into eight categories with clear explanations and practical examples for file management, system information, disk maintenance, networking, process control, scripting, security, and handy utilities.
1️⃣ File and Directory Management
dir: Displays the list of files and folders in the current directory. Example:
dir C:\Windows cd: Changes the current directory path. Example:
cd .. md/ mkdir: Creates a new folder. Example:
md NewFolder rd/ rmdir: Removes an empty directory. Example:
rd OldFolder tree: Shows the folder hierarchy as a tree. Example:
tree D:\ copy: Copies a file to a specified location. Example:
copy a.txt D:\Backup\ xcopy: Copies files and directory trees. Example:
xcopy /E Source Target robocopy: Advanced copy tool with mirroring and resume support. Example:
robocopy C:\Source D:\Target /MIR move: Moves or renames a file or directory. Example:
move a.txt ..\Other\ del/ erase: Deletes files (supports wildcards). Example:
del *.tmp ren/ rename: Renames a file or folder. Example:
ren old.txt new.txt type: Displays the content of a text file directly in the console. Example:
type log.log attrib: Shows or modifies file attributes (read‑only, hidden, etc.). Example:
attrib +H hiddenfile.txt assoc: Views or changes file‑extension associations. Example:
assoc .txt comp: Compares the contents of two files. Example:
comp a.txt b.txt find: Searches for a specific string within files. Example:
find "error" log.log findstr: Advanced search supporting regular expressions. Example:
findstr /S "hello" *.txt replace: Replaces files in a target directory with those from a source directory. Example:
replace C:\Source\*.txt D:\Target\2️⃣ System Information and Management
systeminfo: Shows an overview of OS version, hardware configuration, etc. Example:
systeminfo winver: Pops up a window displaying the Windows version number. Example:
winver ver: Prints the OS version in the console. Example:
ver hostname: Shows the computer's network name. Example:
hostname whoami: Displays the currently logged‑in user name. Example:
whoami driverquery: Lists installed drivers. Example:
driverquery /V msinfo32: Opens the graphical System Information panel. Example:
msinfo32 set: Shows or sets environment variables. Example:
set PATH date: Displays or sets the system date. Example:
date time: Displays or sets the system time. Example:
time shutdown: Shuts down, restarts, or schedules power actions. Example:
shutdown /s /t 36003️⃣ Disk Management and Maintenance
diskpart: Enters the disk partitioning tool. Example:
diskpart → list disk chkdsk: Checks disk errors and attempts repairs. Example:
chkdsk C: /F format: Formats a disk partition. Example:
format D: /FS:NTFS vol: Shows volume label and serial number. Example:
vol D: label: Creates or changes a volume label. Example:
label D: DataDisk defrag: Defragments a disk. Example:
defrag C: /O convert: Converts a FAT volume to NTFS without data loss. Example:
convert D: /FS:NTFS fsutil: Advanced file‑system management tool. Example:
fsutil fsinfo drives wmic: Queries disk model, size, etc., via WMI. Example:
wmic diskdrive get model,size4️⃣ Network Diagnosis and Configuration
ipconfig: Shows IP address and network configuration. Example:
ipconfig /all ping: Tests network connectivity. Example:
ping baidu.com -t tracert: Traces route hops. Example:
tracert baidu.com netstat: Displays network connections and listening ports. Example:
netstat -an nslookup: Queries DNS records. Example:
nslookup baidu.com arp: Shows the ARP cache table. Example:
arp -a getmac: Shows network adapter MAC addresses. Example:
getmac /V route: Views or modifies the routing table. Example:
route print pathping: Traces route with latency statistics. Example:
pathping baidu.com ftp: Enters FTP file‑transfer mode. Example:
ftp ftp.example.com nbtstat: Shows NetBIOS over TCP/IP statistics. Example:
nbtstat -n netsh: Network configuration scripting tool (reset network, view Wi‑Fi passwords, etc.). Example:
netsh wlan show profile5️⃣ Process and Task Management
tasklist: Lists all running processes. Example:
tasklist taskkill: Forces termination of a specific process. Example:
taskkill /F /IM notepad.exe schtasks: Manages scheduled tasks. Example:
schtasks /Query wmic process: Views process details via WMI. Example:
wmic process list brief start: Launches a new window to run a program. Example:
start notepad.exe runas: Runs a program under a different user account. Example:
runas /user:Administrator cmd6️⃣ Batch and Automation Scripting
echo: Displays a message or toggles command echoing. Example:
echo Processing complete! @: Hides the command itself from being echoed. Example:
@echo off pause: Pauses execution and prompts "Press any key to continue". Example:
pause rem: Adds a comment line. Example:
rem This is a comment call: Calls another batch file and returns. Example:
call anotherScript.bat goto: Jumps to a specified label. Example:
goto :end if: Conditional statement. Example:
if exist file.txt del file.txt for: Loops over files or collections. Example:
for %f in (*.txt) do echo %f set: Defines or interactively inputs variables. Example:
set /P name=Enter name: exit: Exits the script or command interpreter. Example:
exit /b color: Sets console foreground and background colors. Example:
color 0A title: Sets the CMD window title. Example:
title My Automation Tool7️⃣ User, Permissions and Security
net user: Manages local user accounts. Example:
net user NewUser Password /add net localgroup: Manages local user groups. Example:
net localgroup Administrators User /add net share: Manages shared folders. Example:
net share ShareName=C:\Folder net use: Connects or disconnects network drives. Example:
net use Z: \\Server\Share net accounts: Views account password policies. Example:
net accounts takeown: Takes ownership of a file or folder. Example:
takeown /F ProtectedFile.txt icacls: Shows or modifies file ACLs. Example:
icacls Folder /grant Username:F cipher: Encrypts or decrypts NTFS files. Example:
cipher /E Secret.docx8️⃣ Handy Utilities
cls: Clears the screen. Example:
cls exit: Closes the CMD window. Example:
exit help: Shows a list of commands or help for a specific command. Example:
help copy /?: Shows detailed syntax for any command. Example:
ping /? cmd: Starts a new command session. Example:
cmd /k powershell: Switches to PowerShell environment. Example:
powershell notepad: Opens Notepad. Example:
notepad calc: Opens Calculator. Example:
calc osk: Opens On‑Screen Keyboard. Example:
osk control: Opens Control Panel. Example:
control taskmgr: Opens Task Manager. Example:
taskmgr regedit: Opens Registry Editor. Example:
regedit gpedit.msc: Opens Group Policy Editor. Example:
gpedit.msc services.msc: Opens Services management console. Example:
services.msc eventvwr: Opens Event Viewer. Example:
eventvwr msconfig: Opens System Configuration utility. Example:
msconfig mstsc: Opens Remote Desktop Connection. Example:
mstsc dxdiag: Opens DirectX Diagnostic Tool. Example:
dxdiag cleanmgr: Opens Disk Cleanup tool. Example: cleanmgr Quick Tips:
Press Win + R, type cmd, and hit Enter to open Command Prompt quickly. Use Win + X and select "Terminal (Admin)" for elevated rights.
Right‑click inside a CMD window to paste content.
Append /? to any command to view detailed syntax, e.g., copy /?.
Remember to separate commands, parameters, and paths with spaces.
Linux Tech Enthusiast
Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
