Welcome! This guide collects commonly used (and some advanced) native Windows Command Prompt (cmd.exe) commands to help with file management, networking, diagnostics, automation, and system administration.
Focus: Classic CMD commands (not full PowerShell coverage). Where a command is deprecated or superseded, a note is included. Many commands require an elevated (Administrator) prompt.
Tips:
- Use
command /?
for built‑in help (often includes switches not listed here). - Prefix with
runas /user:Administrator
or open an elevated terminal when access is denied. - Combine commands with
&&
(only run next if success) or||
(run next if failure). - Use quotes around paths containing spaces:
"C:\Program Files\App"
.
Legend:
- (Admin) means the command typically needs elevation.
- (Deprecated) indicates the command is legacy; prefer the noted alternative.
- File & Directory Management
- Text, Search & Comparison
- Permissions, Security & Ownership
- Disk, Volume & Filesystem Tools
- Networking & Connectivity
- System Information & Diagnostics
- Services, Processes & Scheduling
- Boot, Recovery & Integrity
- User & Account Management
- Environment & Session Utilities
- Scripting & Flow Control (Batch)
- Miscellaneous & Console UX
- Quick Task Examples
dir
– List directory contents (switches:/a
,/s
,/b
,/o
)cd
/chdir
– Change or show current directorymd
/mkdir
– Create directory(ies)rd
/rmdir
– Remove directory (use/s /q
for recursive quiet)copy
– Copy files (simple)xcopy
– Extended copy (legacy; preferrobocopy
for reliability)robocopy
– Robust Copy (retry logic, mirroring, multithread via/MT
)move
– Move/rename file(s)ren
/rename
– Rename file or directorydel
/erase
– Delete file(s) (/f /s /q
options)forfiles
– Select files by date/age/mask for actionstype
– Display file contentsmore
– Paginate output (command | more
)cls
– Clear screentree
– Visual directory treefsutil
(Admin) – Low‑level filesystem info (use cautiously)subst
– Map a path to a virtual drive letterpushd
/popd
– Temporarily switch (and restore) directoriesattrib
– View/change file attributes (+R +H +S +A)where
– Locate executable(s) in PATHcomp
– Byte compare (basic)fc
– File compare (text/binary diff)copy con file.txt
– Quick inline file creation (Ctrl+Z to end)
find
– Search for a string in a file (basic)findstr
– Advanced text search with regex-like syntaxsort
– Sort input or a filemore
– Paginate output (listed above)fc
– Compare files (relisted for context)type
– Output file content (relisted)
icacls
– View/modify NTFS ACLs (replaces legacycacls
/xcacls
)takeown
(Admin) – Take ownership of files/folderscipher
– Encrypt/Decrypt (EFS) + wipe free space (/w
)whoami /groups
– Show group membershipsrunas
– Run a program as another useropenfiles /query
(Admin) – List open network files
chkdsk
(Admin) – Check disk for errorsdiskpart
(Admin) – Disk partition manager (dangerous if misused)format
(Admin) – Format volumeslabel
– Change volume labelmountvol
– Manage volume mount pointsvol
– Display volume label & serialdefrag
– Defragment drivesfsutil
(Admin) – (Also in section 1) advanced operationscleanmgr
– Disk Cleanup utility launchercompact
– Compress/uncompress NTFS filessfc /scannow
(Admin) – System File Checkerdism /online /cleanup-image /restorehealth
(Admin) – Repair component store
ipconfig
– Adapter configuration (/all
,/release
,/renew
,/flushdns
)ping
– Echo testtracert
– Route path to destinationpathping
– Trace + packet loss statisticsarp -a
– ARP cachenbtstat
– NetBIOS over TCP/IP diagnosticsnetstat
– Active connections (-a -n -o
common flags)nslookup
– DNS queries (interactive mode available)route print
– Routing tableroute add|delete
– Edit routesgetmac
– Display MAC addresseshostname
– Show machine nametelnet
– (Optional feature) legacy remote console (Deprecated)ftp
– (Deprecated for secure use; prefer SFTP) basic file transfernet
– Umbrella command:net use
,net share
,net view
, etc.net use
– Map/unmap network drivesnet view
– List network devices/sharesnet share
– Manage shared foldersnet session
– List or close sessionsnet time
– Query time server (legacy)netsh
– Network shell (interface
,wlan
,firewall
,advfirewall
)netsh wlan show profiles
– Saved Wi‑Fi profilesnetdom
(Domain) – Domain trust & join operationscertutil -urlcache * delete
– Clear URL cache (diagnostics/security)
systeminfo
– OS + hardware summaryver
– Windows versionset
– Show environment variablesdriverquery
– Installed drivers listmsinfo32
– System Information GUIwmic
(Deprecated) – WMI queries (use PowerShell CIM/WMI cmdlets)dxdiag
– DirectX diagnosticstasklist
– Running processestasklist /svc
– Map services to processeseventvwr
– Event Viewer (GUI)wevtutil
(Admin) – Query/clear event logsperfmon
– Performance Monitor GUIpowercfg /energy
(Admin) – Power diagnostics reportgpresult /r
– Group Policy resultant setecho %ERRORLEVEL%
– Last command exit code
taskkill /PID <id> /F
– Force terminate processsc query
– Service statussc start|stop|config
– Control servicesservices.msc
– Services GUIschtasks /create
– Schedule tasksschtasks /query /fo LIST /v
– View tasks verbosetimeout /t <seconds>
– Delay executionstart
– Launch a program/window (start "Title" command
)
bcdedit
(Admin) – Boot configurationbootrec
(Recovery Env) – Repair boot recordsreagentc /info
– Windows Recovery Environment (WinRE) statussfc /scannow
(Admin) – System file scan (listed earlier)dism /online /cleanup-image /restorehealth
– Component store repair (listed earlier)
net user
– List/create/modify local usersnet localgroup
– Local group membershipnet group
(Domain) – Domain group managementwhoami
– Current user & SID infowhoami /priv
– Privileges listrunas /user:<User>
– Execute under another accountcontrol userpasswords2
– Advanced user GUIlusrmgr.msc
– Local Users & Groups (not in Home editions)
set
– Display/set session environment variablessetx
– Persist environment variables (new sessions only)path
– View/edit PATH (session)title
– Set console window titlecolor
– Set console colorsmode con
– Console dimensions and bufferecho
– Output text / toggle command echoingpause
– Wait for user keystrokecall
– Invoke another batch file and returnexit
– Exit CMD / set errorlevel:exit /b 1
for
– Iterate (files, strings, numbers);for /?
for formsif
– Conditional execution (string, errorlevel, exist)goto
– Jump to labelchoice
– Prompt for user selection, sets%ERRORLEVEL%
shift
– Shift batch parameters%1..%9
set /a
– Arithmetic operationsrem
or::
– Comments>
,>>
– Redirect (overwrite / append)2>&1
– Merge stderr into stdout|
– Pipe output to another command
help
– Built-in help indexassoc
– File extension associationsftype
– File type command mappingtime
– Show/set system timedate
– Show/set system dateshutdown /s /t 0
– Immediate shutdownshutdown /r /t 0
– Immediate restartshutdown /h
– Hibernateshutdown /l
– Log offshutdown /a
– Abort pending shutdownmsconfig
– System Configuration GUImmc
– Microsoft Management Consoletaskmgr
– Task Managerclip
– Redirect output to clipboard (e.g.,ipconfig | clip
)
Create a directory tree and move files:
md logs\archived && move *.log logs\
Find lines containing ERROR (case-insensitive) in all .txt
files:
findstr /i /n /s /c:"ERROR" *.txt
Mirror a directory to backup (with logging):
robocopy C:\Source D:\Backup /MIR /R:2 /W:2 /LOG:backup.log
Kill a hung process by name:
taskkill /IM notepad.exe /F
List top TCP listeners:
netstat -ano | findstr LISTENING
Set a persistent environment variable (new sessions only):
setx APP_ENV production
Generate a power efficiency report (HTML):
powercfg /energy /output energy-report.html
Flush DNS cache:
ipconfig /flushdns
wmic
– Deprecated; prefer PowerShell CIM cmdlets.telnet
,ftp
– Insecure; use SSH/SFTP alternatives.xcopy
– Superseded for most tasks byrobocopy
.deltree
– Removed after Windows 9x era (userd /s
).xcacls
/cacls
– Deprecated; useicacls
.
Commands like diskpart
, format
, bcdedit
, bootrec
, dism
, and sfc
can cause system instability or data loss if misused. Always verify targets and consider backing up important data.
We welcome contributions! If you'd like to contribute to this project, please check out our Contribution Guidelines.
Please review our Code of Conduct before participating in this project.
This project is licensed under the License.