The Command Prompt may look like a relic of the computing past, but it remains one of Windows’ most powerful tools. It is usually hidden behind a simple text interface, but behind it lies a control center that can perform tasks impossible through the graphical interface alone. If you are a Windows user, it is no surprise that you might have or do interact with the Windows Command Prompt daily through a set of commands to save time, solve problems, or even unlock capabilities that aren’t accessible any other way.
In this day and age where everything is digital, Knowing the right command prompt to use is important for various widows, be it IT professionals, developers, or even everyday users. There are between 1,500 to 3,000+ commands, depending on your system setup, installed tools, and Windows version, available for your own use, and this guide covers all that you need to know and master for everyday use.
Essential CMD Commands Every Windows User Should Know
Below is a complete list of Command Prompt commands, often called CMD commands, for all Windows versions
Most Commonly Used Commands
Command | Description | Syntax | Example | Notes/Tips |
---|---|---|---|---|
cd | Changes the current directory | cd followed by the path | cd C:\Users\Documents | Use cd .. to move up one directory level. Use cd \ to go to drive root. |
dir | Lists files and directories | dir followed by options and path | dir /a /s *.txt | /a shows hidden files, /s includes subdirectories. |
copy | Copies files | copy followed by source and destination | copy report.txt backup\ | Use /y to suppress confirmation prompts. |
del | Deletes files | del followed by filename | del old_report.txt | Use with caution; deleted files do not go to the Recycle Bin. |
mkdir or md | Creates a new directory | mkdir followed by directory name | mkdir projects | Can create multiple nested directories with /s . |
rmdir or rd | Removes a directory | rmdir followed by directory name | rmdir old_projects | Use /s to delete directory and all its content. |
type | Displays contents of a text file | type followed by filename | type readme.txt | Useful for quick viewing without opening an editor. |
echo | Displays messages or toggles command echoing | echo followed by message | echo Hello World | Can redirect output to files using echo text > file.txt. |
cls | Clears the screen | cls | cls | Useful for decluttering the command prompt window. |
find | Searches for text strings in files | find followed by string and filename | find “error” log.txt | Use /i for case-insensitive search. |
ipconfig | Displays network configuration | ipconfig with or without options | ipconfig /all | /all shows detailed network configuration. |
ping | Tests network connectivity | ping followed by host | ping google.com | Use -t for continuous ping until stopped manually. |
netstat | Displays network statistics | netstat followed by options | netstat -an | -a shows all connections, -n shows numerical addresses. |
tasklist | Lists running processes | tasklist with or without options | tasklist /fi “username eq administrator” | /fi allows filtering by various criteria. |
taskkill | Terminates processes | taskkill using process ID or name | taskkill /im notepad.exe | Use /f to force termination. |
systeminfo | Displays system information | systeminfo | systeminfo | Provides comprehensive details about the system. |
sfc | Runs System File Checker | sfc followed by /scannow | sfc /scannow | Scans and repairs Windows system files. |
chkdsk | Checks disk for errors | chkdsk followed by drive and parameters | chkdsk C: /f | /f fixes errors, may require restart when checking system drives. |
shutdown | Shuts down or restarts the computer | shutdown followed by options | shutdown /r /t 60 | /r restarts, /t sets time delay in seconds before action. |
help | Displays help information for commands | help followed by command name | help dir | Shows detailed syntax and options for the specified command. |
Complete Command Reference
Commands A-C
Command | Primary Function | Full Syntax | Example Usage | Windows Version Compatibility |
---|---|---|---|---|
assoc | View or modify file extension associations | assoc [.ext[=[fileType]]] | assoc .txt=txtfile | Windows XP and later |
at | Schedule commands and programs (deprecated) | at [\computername] time [/interactive] [/every:date] [/next:date] “command” | at 14:30 “backup.bat” | Windows XP to Windows 8 (replaced by schtasks) |
attrib | Display or change file attributes | attrib [+r | -r] [+a | -a] [+s |
bcdboot | Configure boot files | bcdboot source [/l locale] [/s volume-letter] [/v] [/m [{OS-loader-GUID}]] [/addlast | /p] | bcdboot C:\Windows /s D: |
bcdedit | Manage boot configuration data | bcdedit [/store filename] command [options] | bcdedit /set {default} bootmenupolicy legacy | Windows Vista and later |
break | Set or clear extended CTRL+C checking | break [on | off] | break on |
cacls | Display or modify file access control lists (deprecated) | cacls filename [/t] [/e] [/c] [/g user:perm] [/r user […]] [/p user:perm […]] [/d user […]] | cacls file.txt /g User:F | Windows XP (replaced by icacls) |
call | Call one batch program from another | call [drive:][path]filename [batch-parameters] | call subroutine.bat param1 | All Windows versions |
cd or chdir | Change directory | cd [/d] [drive:][path] | cd /d D:\Projects | All Windows versions |
chcp | Change active code page | chcp [nnn] | chcp 1252 | All Windows versions |
chkdsk | Check disk for errors | chkdsk [volume[[path]filename]] [/f] [/v] [/r] [/x] [/i] [/c] [/l[:size]] [/b] | chkdsk C: /f /r | All Windows versions |
chkntfs | Display or modify automatic disk checking | chkntfs volume […] [/d] [/t[:time]] [/x volume […]] [/c volume […]] | chkntfs C: /x | Windows XP and later |
choice | Prompt user to select from choices | choice [/c choices] [/n] [/cs] [/t timeout /d choice] [/m text] | choice /c YN /m “Continue?” | Windows XP and later |
cipher | Display or alter file encryption | cipher [/e | /d | /c] [/s:dir] [/b] [/h] [/k] [/f] [/u[/n]] [/w:dir] [/a] [/i] [/m] [pathname […]] |
clip | Copy command output to clipboard | commandclip | dirclip | All Windows versions |
cls | Clear the screen | cls | cls | All Windows versions |
cmd | Start a new command prompt | cmd [/a | /u] [/q] [/d] [/e:on | /e:off] [/f:on |
color | Change console foreground and background colors | color [attr] | color 0A | Windows XP and later |
comp | Compare the contents of two files | comp [data1] [data2] [/d] [/a] [/l] [/n=number] [/c] | comp file1.txt file2.txt | All Windows versions |
compact | Display or change file compression | compact [/c | /u] [/s[:dir]] [/a] [/i] [/f] [/q] [filename […]] | compact /c /s:C:\Documents |
convert | Convert FAT to NTFS | convert volume /fs:ntfs [/v] [/cvtarea:filename] [/nosecurity] [/x] | convert D: /fs:ntfs | All Windows versions |
copy | Copy files | copy [/d] [/v] [/n] [/y | /-y] [/z] [/l] [/a | /b] source [/a |
Commands D-I
Command | Primary Function | Full Syntax | Example Usage | Windows Version Compatibility |
---|---|---|---|---|
date | Display or set date | date [/t | date] | date 12-25-2023 | All Windows versions |
defrag | Defragment disk | defrag volume [/a] [/f] [/v] [/r] [/x] [/b] [/w] [/d] | defrag C: /v | All Windows versions |
del or erase | Delete files | del [/p] [/f] [/s] [/q] [/a[[:]attributes]] names | del /s *.tmp | All Windows versions |
dir | List files and directories | dir [drive:][path][filename] [/a[[:]attributes]] [/b] [/c] [/d] [/l] [/n] [/o[[:]sortorder]] [/p] [/q] [/s] [/t[[:]timefield]] [/w] [/x] [/4] | dir /a /s *.doc | All Windows versions |
diskcomp | Compare contents of two floppy disks | diskcomp [drive1: [drive2:]] | diskcomp A: B: | All Windows versions |
diskcopy | Copy contents of one floppy disk to another | diskcopy [drive1: [drive2:]] [/v] | diskcopy A: B: /v | All Windows versions |
diskpart | Disk partitioning tool | diskpart | diskpart | Windows XP and later |
doskey | Edit command line, recall commands, create macros | doskey [/reinstall] [/listsize=size] [/macros[:all | :exename]] [/history] [/insert | /overstrike] [/exename=exename] [/macrofile=filename] [macroname=[text]] | doskey /history | All Windows versions |
driverquery | Display installed device drivers | driverquery [/s system [/u username [/p [password]]]] [/fo {table | list | csv}] [/nh] [/v] | driverquery /fo csv /v | Windows XP and later |
echo | Display messages or toggle command echoing | echo [on | off | message] | echo Processing files… | All Windows versions |
endlocal | End localization of environment changes | endlocal | endlocal | All Windows versions |
erase | Delete files (same as del) | erase [/p] [/f] [/s] [/q] [/a[[:]attributes]] names | erase /p confidential.txt | All Windows versions |
eventcreate | Create custom event in event log | eventcreate [/s computer [/u domain\user [/p password]]] /id eventid [/l {APPLICATION|SYSTEM}] [/so srcname] [/t {ERROR|WARNING|INFORMATION|SUCCESSAUDIT|FAILUREAUDIT}] /d description | eventcreate /id 1000 /t ERROR /d “Backup failed” | Windows XP and later |
exit | Exit the command prompt or script | exit [/b] [exitCode] | exit /b 1 | All Windows versions |
expand | Extract files from compressed files | expand [-r] source destination | expand -r archive.cab C:\files\ | All Windows versions |
fc | Compare files | fc [/a | /b] [/c] [/l] [/lb n] [/n] [/off[line]] [/t] [/u] [/w] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2 | fc /b file1.exe file2.exe | All Windows versions |
find | Search for text string in files | find [/v] [/c] [/n] [/i] [/off[line]] “string” [[drive:][path]filename[…]] | find /i “error” log.txt | All Windows versions |
findstr | Search for patterns in files | findstr [/b] [/e] [/l] [/r] [/s] [/i] [/x] [/v] [/n] [/m] [/o] [/p] [/f:file] [/c:string] [/g:file] [/d:dirlist] [/a:colorattribute] [/off[line]] strings [[drive:][path]filename[…]] | findstr /i /s “warning” *.log | Windows XP and later |
finger | Display information about remote user | finger [user]@host | finger jdoe@server | Windows XP (limited support) |
for | Loop through a set of items | for [/d] [/r [path]] [/l [initial] [step] [end]] [/f [“options”] [“string”] [/c cmd] [/v var]] {%%parameter | %parameter} in (set) do command | for %i in (*.txt) do echo %i | All Windows versions |
forfiles | Process files in batch | forfiles [/p pathname] [/m searchmask] [/s] [/c command] [/d [+ | -] date] | forfiles /p C:\ /s /m *.txt /d -30 /c “cmd /c del @path” | Windows Vista and later |
format | Format disk for Windows | format volume [/fs:filesystem] [/v:label] [/q] [/a:size] [/c] [/x] [/p:passes] [/s:source] | format F: /fs:ntfs /q | All Windows versions |
fsutil | File system utility | fsutil [command] [options] | fsutil fsinfo volumeinfo C: | Windows XP and later |
ftp | File Transfer Protocol client | ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [host] | ftp -s:commands.txt ftp.example.com | All Windows versions |
ftype | Display or modify file type associations | ftype [fileType[=[openCommandString]]] | ftype txtfile=”notepad.exe %1″ | Windows XP and later |
getmac | Display MAC address of network adapters | getmac [/s computer [/u domain\user [/p password]]] [/fo {TABLE | LIST | CSV}] [/nh] [/v] | getmac /v | Windows XP and later |
goto | Jump to labeled line in batch file | goto label | goto error_handler | All Windows versions |
gpresult | Display Group Policy settings | gpresult [/s computer [/u domain\user [/p [password]]]] [/user targetusername] [/scope {user | computer}] [/r | /v | /z] [/x | /h filename ] | gpresult /r | Windows XP and later |
help | Display help information | help [command] | help dir | All Windows versions |
hostname | Display computer name | hostname | hostname | All Windows versions |
icacls | Display or modify file access control lists | icacls name [/grant[:r] sid:perm] [/deny sid:perm […]] [/remove[:g|:d]] sid[…]] [/t] [/c] [/l] [/q] [/setintegritylevel level] | icacls file.txt /grant Users:R | Windows Vista and later |
if | Perform conditional processing | if [not] errorlevel number command or if [not] string1==string2 command or if [not] exist filename command | if exist file.txt echo File exists | All Windows versions |
ipconfig | Display IP configuration | ipconfig [/all | /renew [adapter] | /release [adapter] | /flushdns | /displaydns | /registerdns | /showclassid adapter | /setclassid adapter [classid]] | ipconfig /all | All Windows versions |
Commands J-P
Command | Primary Function | Full Syntax | Example Usage | Windows Version Compatibility |
---|---|---|---|---|
label | Create, change, or delete volume label | label [drive:][label] | label C:SYSTEM | All Windows versions |
logman | Manage performance logs | logman [create|query|start|stop|delete|update|import|export] [options] | logman create counter log1 -c “\Processor(_Total)% Processor Time” | Windows XP and later |
logoff | Log off user | logoff [sessionname|sessionid] [/server:servername] [/v] | logoff | Windows XP and later |
makecab | Create cabinet (.cab) files | makecab [source] [destination] [/v[n]] [/d var=value …] [/l dir] | makecab file.txt archive.cab | Windows XP and later |
md or mkdir | Create directory | md [drive:]path | md C:\Projects\New | All Windows versions |
mklink | Create symbolic links | mklink [[/d] | [/h] | [/j]] Link Target | mklink /d LinkDir TargetDir | Windows Vista and later |
mode | Configure system devices | mode com[m] [baud=b] [parity=p] [data=d] [stop=s] [to=on|off] [xon=on|off] [odsr=on|off] [octs=on|off] [dtr=on|off|hs] [rts=on|off|hs|tg] [idsr=on|off] or mode con[:] [cols=c] [lines=n] | mode con: cols=80 lines=25 | All Windows versions |
more | Display output one screen at a time | more [/e] [/c] [/p] [/s] [/tn] [+n] [files] | dir /s more | All Windows versions |
mountvol | Create, delete, or list volume mount points | mountvol [drive:path | drive: | path] [volumename | /d | /l | /p | /r | /n | /e] | mountvol D: \?\Volume{GUID}\ | Windows XP and later |
move | Move files | move [/y | /-y] [drive:][path]filename1[,…] destination | move *.txt C:\Archive\ | All Windows versions |
msinfo32 | Display system information | msinfo32 [/categories {+ | – | n |
msiexec | Windows Installer tool | msiexec /option [parameters] | msiexec /i program.msi | Windows XP and later |
nbtstat | Display NetBIOS over TCP/IP statistics | nbtstat [-a RemoteName] [-A IP address] [-c] [-n] [-r] [-R] [-RR] [-s] [-S] [interval] | nbtstat -a ComputerName | All Windows versions |
net | Network command group | net [accounts | computer | config | continue | file | group | help | helpmsg | localgroup | name | pause | print | send | session | share | start | statistics | stop | time | use | user | view] | net user | All Windows versions |
netsh | Network shell | netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName]UserName] [-p Password | *] [Command | -f ScriptFile] | netsh interface show interface | Windows XP and later |
netstat | Display network statistics | netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval] | netstat -ano | All Windows versions |
nslookup | Query DNS servers | nslookup [-subcommand] [computerToFind | [-server]] | nslookup google.com | All Windows versions |
openfiles | Display or disconnect files opened remotely | openfiles /query [/s system [/u username [/p [password]]]] [/fo {TABLE | LIST | CSV}] [/nh] [/v] [/disconnect [/a id] [/se sessions] [/op openfile]] | openfiles /query | Windows XP and later |
path | Display or set command search path | path [[drive:]path[;…][;%path%]] | path %path%;C:\Scripts | All Windows versions |
pathping | Trace route plus network latency | pathping [-g host-list] [-h maximum_hops] [-i address] [-n] [-p period] [-q num_queries] [-w timeout] [-4] [-6] target_name | pathping -n google.com | Windows XP and later |
pause | Pause batch file execution | pause | pause | All Windows versions |
perfmon | Performance Monitor | perfmon [/res | /report | /sys | /rel] | perfmon /res | Windows XP and later |
ping | Test network connectivity | ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-c compartment] [-p] [-4] [-6] target_name | ping -n 5 google.com | All Windows versions |
popd | Restore directory changed by pushd | popd | popd | All Windows versions |
powercfg | Manage power settings | powercfg [-option] [arguments…] | powercfg /list | Windows XP and later |
powershell | Windows PowerShell | powershell [options] [-Command {- | script-block [-args arg-array] | string [command-arguments] | – file file-path [args]}] | powershell -ExecutionPolicy Bypass -File script.ps1 | Windows 7 and later |
Print text file | print [/d:device] [[drive:][path]filename[…]] | print document.txt | All Windows versions | |
prompt | Change command prompt | prompt [text] | prompt $p$g | All Windows versions |
pushd | Save current directory and change to new one | pushd [path] | pushd \server\share | All Windows versions |
Commands Q-Z
Command | Primary Function | Full Syntax | Example Usage | Windows Version Compatibility |
---|---|---|---|---|
qprocess | Display processes | qprocess {* | processname | processid} [/s computer [/u domain\user [/p password]]] | qprocess * | Windows XP and later |
query | Display various system information | query [process | session | termserver | user] [options] | query user | Windows XP and later |
rd or rmdir | Remove directory | rd [/s [/q]] [drive:]path | rd /s /q OldProject | All Windows versions |
recover | Recover readable info from damaged disk | recover [drive:][path]filename | recover damaged.doc | All Windows versions |
reg | Registry manipulation | reg [operation] [parameters] | reg query HKLM\Software | Windows XP and later |
regsvr32 | Register/unregister DLL | regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname | regsvr32 library.dll | Windows XP and later |
rem | Record comments in batch files | rem [comment] | rem This is a comment | All Windows versions |
ren or rename | Rename files | ren [drive:][path]filename1 filename2 | ren oldname.txt newname.txt | All Windows versions |
replace | Replace files | replace [drive1:][path1]filename [drive2:][path2] [options] | replace c:\file.txt d:\backup\ | All Windows versions |
reset | Reset a session | reset session [/server:servername] [/v] | reset session 1 | Windows XP and later |
robocopy | Robust file copy | robocopy source destination [file […]] [options] | robocopy C:\Data D:\Backup /mir | Windows Vista and later |
route | Manipulate network routing tables | route [-f] [-p] [command [destination] [mask netmask] [gateway] [metric metric] [if interface]] | route print | All Windows versions |
runas | Run command as different user | runas [{/user:domain\username | /smartcard}] [options] program | runas /user:DOMAIN\Admin cmd | Windows XP and later |
sc | Service Control | sc [\server] [command] [service_name] [options] | sc query wuauserv | Windows XP and later |
schtasks | Schedule tasks | schtasks [/option [arguments]] | schtasks /create /tn “Backup” /tr backup.bat /sc daily | Windows XP and later |
set | Display or set environment variables | set [variable=[string]] | set PATH=%PATH%;C:\bin | All Windows versions |
setlocal | Begin localization of environment changes | setlocal [enableextensions | disableextensions] [enabledelayedexpansion | disabledelayedexpansion] | setlocal enabledelayedexpansion | All Windows versions |
setx | Set environment variables permanently | setx [/s computer [/u [domain]user [/p [password]]]] var value [/m] | setx JAVA_HOME “C:\Program Files\Java\jdk1.8.0_92” | Windows XP and later |
sfc | System File Checker | sfc [/scannow] [other options] | sfc /scannow | Windows XP and later |
shift | Shift position of batch parameters | shift [/n] | shift | All Windows versions |
shutdown | Shutdown or restart computer | shutdown [options] | shutdown /r /t 60 | All Windows versions |
sort | Sort input | sort [options] [[file1] [/o file2]] | dir | sort /+10 | All Windows versions |
start | Start program in a new window | start [“title”] [options] [command] [parameters] | start notepad report.txt | All Windows versions |
subst | Associate path with drive letter | subst [drive1: [drive2:]path] | subst X: C:\LongPath\Projects | All Windows versions |
systeminfo | Display system information | systeminfo [/s computer [/u domain\user [/p password]]] [/fo {TABLE | LIST | CSV}] [/nh] | systeminfo /fo csv | Windows XP and later |
takeown | Take ownership of file | takeown [/f file [/a] [/r [/d]]] [/s computer [/u [domain]user [/p [password]]]] | takeown /f important.doc | Windows Vista and later |
taskkill | Terminate tasks/processes | taskkill [options] [/pid id | /im name] | taskkill /im notepad.exe /f | Windows XP and later |
tasklist | List running tasks/processes | tasklist [options] | tasklist /v | Windows XP and later |
time | Display or set system time | time [/t | time] | time 14:30 | All Windows versions |
timeout | Wait for specified seconds | timeout /t seconds [/nobreak] | timeout /t 10 | Windows Vista and later |
title | Set console window title | title [string] | title Command Processor | Windows XP and later |
tracert | Trace route to host | tracert [options] target_name | tracert -d google.com | All Windows versions |
tree | Display directory structure graphically | tree [drive:][path] [/f] [/a] | tree C:\ /f | All Windows versions |
type | Display contents of text files | type [drive:][path]filename | type config.ini | All Windows versions |
tzutil | Time zone utility | tzutil [/g] [/s timezoneid] [/l] | tzutil /s “Eastern Standard Time” | Windows Vista and later |
ver | Display Windows version | ver | ver | All Windows versions |
verify | Verify files were written correctly | verify [on | off] | verify on | All Windows versions |
vol | Display disk volume label and serial number | vol [drive:] | vol C: | All Windows versions |
where | Locate files | where [/r dir] [/q] [/f] [/t] pattern… | where /r C:\ notepad.exe | Windows XP and later |
whoami | Display current user | whoami [options] | whoami /all | Windows XP and later |
windiff | Compare files or directories | windiff [options] file1 file2 | windiff oldfile.txt newfile.txt | Windows XP (may require install) |
wmic | Windows Management Instrumentation Command | wmic [global switches] [alias] [verb] [properties] | wmic process list full | Windows XP to 10 (deprecated in 10) |
wscript | Windows Script Host | wscript [options] scriptname [arguments…] | wscript //nologo script.vbs | All Windows versions |
xcopy | Copy files and directories | xcopy source [destination] [options] | xcopy C:\Source D:\Backup /s /e /h /i | All Windows versions |