The CMD commands you will use most are dir (list files), cd (change folder), copy, move, del, mkdir, ipconfig, ping, tasklist, taskkill and systeminfo. Type help in Command Prompt for a list, and add /? to any command (such as dir /?) for its full syntax.
The tables below group 45 commands by job. Outputs shown are example output from Windows 11 (build 22631), with paths shortened. Commands marked "admin" need a Command Prompt opened with Run as administrator.
Files and folders
| Command | What it does | Example |
|---|---|---|
dir | List files and folders | dir /a (include hidden), dir /s *.pdf (search subfolders) |
cd | Show or change the current folder | cd .., cd /d D:\work |
mkdir / md | Create a folder | mkdir reports\2026 |
rmdir / rd | Delete a folder | rmdir old (must be empty), rmdir /s old |
copy | Copy files | copy notes.txt D:\backup\ |
xcopy | Copy files and folder trees | xcopy C:\src D:\dst /e /i |
robocopy | Copy large trees, resumable, with logging | robocopy C:\src D:\dst /e /z |
move | Move or rename files and folders | move report.docx archive\ |
ren | Rename a file | ren draft.txt final.txt |
del / erase | Delete files (not to the Recycle Bin) | del *.tmp |
type | Print a text file | type notes.txt |
more | Show output one screen at a time | type log.txt | more |
tree | Draw the folder structure | tree /f (include files) |
attrib | Show or change file attributes | attrib -h -s file.txt |
findstr | Search text in files | findstr /s /i "error" *.log |
where | Find which executable runs for a name | where python |
fc | Compare two files | fc old.txt new.txt |
Example output of dir in a small folder:
Directory of C:\work\cmdtest
2026-10-26 14:11 <DIR> .
2026-10-26 14:11 <DIR> ..
2026-10-26 14:11 8 notes.txt
2026-10-26 14:11 8 old.txt
2026-10-26 14:11 <DIR> sub
2 File(s) 16 bytes
3 Dir(s) 362 145 714 176 bytes free
Two details trip people up. First, cd D:\work from drive C changes D's current folder but leaves you on C; add /d to switch drive too, or type D: first. Second, rmdir refuses a folder that still has files in it and prints The directory is not empty; /s deletes the whole tree.
Networking
| Command | What it does | Example |
|---|---|---|
ipconfig | Show IP address, gateway and DNS settings | ipconfig /all |
ipconfig /flushdns | Clear the DNS cache | ipconfig /flushdns |
ipconfig /release, /renew | Drop and request a DHCP address | ipconfig /renew |
ping | Test whether a host answers | ping -n 4 example.com |
tracert | Show each router on the way to a host | tracert example.com |
pathping | Trace route plus packet loss per hop | pathping example.com |
nslookup | Query DNS | nslookup example.com |
netstat | List connections and listening ports | netstat -ano |
arp | Show the IP-to-MAC address cache | arp -a |
getmac | Show network adapter MAC addresses | getmac /v |
netsh | Configure networking, firewall, Wi-Fi | netsh wlan show profiles |
hostname | Print the computer name | hostname |
More detail: the ping command and flushing the DNS cache. netstat -ano is also the first step in fixing "port already in use".
Processes and the system
| Command | What it does | Example |
|---|---|---|
tasklist | List running processes with PIDs | tasklist /FI "IMAGENAME eq explorer.exe" |
taskkill | End a process | taskkill /PID 18244 /F, taskkill /IM notepad.exe |
systeminfo | OS version, install date, RAM, hotfixes | systeminfo |
ver | Windows version number | ver |
whoami | Current user (and groups with /groups) | whoami |
set | Show or set environment variables for this window | set PATH |
setx | Set an environment variable permanently | setx MY_VAR "value" |
sc query | Show Windows service status | sc query wuauserv |
schtasks | List or create scheduled tasks | schtasks /query |
shutdown | Shut down, restart or sign out | shutdown /r /t 0 |
cls | Clear the screen | cls |
exit | Close Command Prompt | exit |
Example output:
C:\>ver
Microsoft Windows [Version 10.0.22631.6199]
C:\>tasklist /FI "IMAGENAME eq explorer.exe"
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
explorer.exe 77888 Console 2 197 792 K
Windows 11 still reports version 10.0 here; the build number (22631) is what identifies the release. Variables set with set vanish when the window closes, while setx writes them permanently but only new windows see them. See setting environment variables for the details.
For shutdown: /s shuts down, /r restarts, /t sets the delay in seconds (default 30), and shutdown /a cancels a pending shutdown during that delay. shutdown /r /fw restarts into the UEFI firmware settings, which saves hunting for the right key at boot.
Disks and system repair
| Command | What it does | Example |
|---|---|---|
chkdsk | Check a disk's file system (admin) | chkdsk C: (report only), chkdsk C: /f |
sfc | Verify and repair protected system files (admin) | sfc /scannow |
vol | Show a drive's label and serial number | vol C: |
fsutil | File system settings and queries (admin) | fsutil behavior query DisableDeleteNotify |
diskpart | Partition and format disks (admin) | Interactive: list disk |
defrag | Optimise a drive: defrag an HDD, TRIM an SSD (admin) | defrag C: /o |
sfc /scannow "scans the integrity of all protected system files and repairs files with problems when possible", according to Microsoft's reference. chkdsk without switches only reports; /f fixes errors and /r also scans for bad sectors. On the system drive, chkdsk C: /f can't lock the volume, so it asks: Chkdsk cannot run because the volume is in use by another process. Would you like to schedule this volume to be checked the next time the system restarts? (Y/N)
Commands that delete without asking
CMD has no undo, and these do not use the Recycle Bin:
del /s /q *.*deletes every file in the folder and all subfolders, silently.rmdir /s /q folderdeletes the folder tree with no confirmation. Microsoft's reference warns: "the entire directory tree is deleted without confirmation".robocopy src dst /mirmirrors the source, which means it deletes files in the destination that don't exist in the source. Point it at the wrong destination and it empties it./miris documented as/eplus/purge.formatanddiskpart'scleanwipe whole volumes or disks.
Before running any of these, run cd on its own to confirm where you are, and do a dry run where one exists: robocopy's /l switch lists what it would copy or delete without touching anything.
Error messages you'll see
| Message | Meaning |
|---|---|
'xyz' is not recognized as an internal or external command, operable program or batch file. | Typo, or the program's folder isn't in PATH. Check with where xyz. |
Access is denied. | Needs an administrator prompt, or the file is in use or protected. |
The system cannot find the file specified. | Wrong name or wrong folder. Run dir to check. |
Could Not Find C:\work\missing.txt | del found nothing matching the name. |
The directory is not empty. | rmdir without /s on a folder with files. |
Useful tricks
- Redirect output to a file:
ipconfig /all > network.txt(overwrite) or>>(append). - Copy output to the clipboard:
systeminfo | clip. - Chain commands:
a && bruns b only if a succeeded;a & bruns both regardless. - Tab completion: press Tab to complete file and folder names.
- History: the Up arrow recalls earlier commands, and F7 shows a list of them.
If you also work on Linux or macOS, basic Linux commands maps most of these: dir is ls, type is cat, findstr is grep, tasklist is ps.
Frequently asked questions
- How do I open Command Prompt?
- Press Win+R, type cmd and press Enter. For an administrator prompt, type cmd in the Start menu search, right-click Command Prompt and choose Run as administrator. In Windows Terminal, open a new tab and pick Command Prompt from the drop-down list.
- How do I see all CMD commands?
- Type help in Command Prompt for a list of common commands with one-line descriptions, then add /? to any command (for example dir /?) for its full syntax. Microsoft Learn's Windows commands reference lists every command alphabetically.
- Are CMD commands case-sensitive?
- No. DIR, dir and Dir do the same thing, and Windows file names are not case-sensitive by default either. Switches such as /S and /s are also treated the same.
- Should I use CMD or PowerShell?
- Both run these commands. Microsoft recommends PowerShell for new automation because its cmdlets return objects instead of text, but CMD is still fine for quick one-off commands and existing .bat files. A few CMD built-ins behave differently in PowerShell, where dir and del are aliases for PowerShell cmdlets with different switches.