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:Administratoror 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 /qfor recursive quiet)copyβ Copy files (simple)xcopyβ Extended copy (legacy; preferrobocopyfor 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 /qoptions)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 -ocommon 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..%9set /aβ Arithmetic operationsremor::β 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.