Windows CMD Command Cheat Sheet
The Windows Command Prompt (CMD) is the command-line interpreter for Windows operating systems. It allows users to execute programs, manage files, and configure system settings by typing text commands.
File and Directory Operations
| Command | Description | Example |
|---|---|---|
cd |
Change current directory | cd C:\Users |
dir |
List files and folders in current directory | dir /p |
copy |
Copy files | copy file.txt D:\backup |
move |
Move or rename files/directories | move old.txt new.txt |
del |
Delete one or more files | del test.txt |
mkdir |
Create a new directory | mkdir NewFolder |
rmdir |
Delete a directory | rmdir /s OldFolder |
ren |
Rename a file or directory | ren file.txt newfile.txt |
type |
Display contents of a text file | type readme.txt |
find |
Search for a string in files | find "error" log.txt |
Network Diagnostics
| Command | Description | Example |
|---|---|---|
ping |
Test network connection | ping google.com |
ipconfig |
Display network adapter configuration | ipconfig /all |
tracert |
Route trace, determines packet path | tracert example.com |
netstat |
Display active network connections and port status | netstat -an |
nslookup |
Query DNS information | nslookup google.com |
getmac |
Get the MAC address of network cards | getmac |
System Management
| Command | Description | Example |
|---|---|---|
systeminfo |
Display detailed system information | systeminfo |
tasklist |
List all currently running processes | tasklist |
taskkill |
End one or more processes | taskkill /IM notepad.exe /F |
chkdsk |
Check disk for errors | chkdsk C: /f |
gpupdate |
Refresh Group Policy settings | gpupdate /force |
sfc /scannow |
Scan and repair system files | sfc /scannow |
shutdown |
Shut down or restart the computer | shutdown /r /t 0 (Immediate restart) |
Other Useful Commands
| Command | Description | Example |
|---|---|---|
cls |
Clear the screen | cls |
echo |
Display messages or toggle echo | echo Hello World |
help |
Get help information for a command | help dir |
attrib |
Display or change file attributes | attrib +h file.txt (Hide file) |
path |
Display or set search path | path |
exit |
Exit the Command Prompt window | exit |
Tips and Shortcuts
- Auto-completion: Type the first few letters of a command or filename and press
Tabto auto-complete. - View History: Press
F7to bring up a list of command history, or use up and down arrow keys. - Aborting Commands: Use
Ctrl + Cto force stop a running command. - Redirection Output:
>: Save output to a new file (overwrite).>>: Append output to an existing file.- Example:
dir > filelist.txt