Windows Command Prompt (CMD) Basics Cheat Sheet

1. Opening Command Prompt

  • Method 1: Press Win + R, type cmd, and press Enter.
  • Method 2: Search for “Command Prompt” in the Start menu.
  • Method 3: Shift + Right Click in any folder → “Open Command Window Here”.

2. Basic Navigation

1. Check Current Directory

cd

2. List Files and Folders

dir

3. Change Directory

cd <folder>

Example:

cd Documents

4. Move Up One Directory

cd ..

5. Go to Root Directory

cd \

6. Open Specific Drive

D:

3. File and Folder Management

1. Create a Folder

mkdir <foldername>

Example:

mkdir Projects

2. Create an Empty File

echo. > filename.txt

3. Delete a File

del <filename>

4. Delete a Folder

rmdir <foldername> /s

/s – Deletes all contents in the folder.
/q – Quiet mode (no prompts).


5. Rename a File/Folder

rename <oldname> <newname>

6. Copy Files

copy <source> <destination>

Example:

copy file.txt D:\Backup

7. Move Files

move <source> <destination>

Example:

move file.txt D:\Archive

4. System Information and Diagnostics

1. Check IP Address

ipconfig

2. Display Network Details

ipconfig /all

3. Test Network Connection (Ping)

ping google.com

4. View Active Connections

netstat

5. System Information

systeminfo

6. View Running Processes

tasklist

7. Kill a Process

taskkill /IM <processname> /F

Example:

taskkill /IM notepad.exe /F

5. Disk Management

1. Check Disk Space

chkdsk

2. Format a Drive

format D:

3. Display Disk Information

diskpart

Type list disk in DiskPart prompt to see available drives.


6. User and System Management

1. List All Users

net user

2. Add a New User

net user <username> <password> /add

3. Delete a User

net user <username> /delete

4. Shutdown / Restart

shutdown /s /t 60

/s – Shutdown
/r – Restart
/t 60 – Delay in seconds


5. Abort Shutdown

shutdown /a

7. File Search and Filtering

1. Search for Files

dir filename /s

2. Find Specific Text in Files

find "text" <file>

3. List Files with Specific Extensions

dir *.txt

8. Environment Variables

1. View Environment Variables

set

2. Set a New Environment Variable

setx PATH "C:\Program Files\Python39"

9. Permissions and Ownership

1. Check Folder Permissions

icacls <folder>

2. Change Folder Permissions

icacls <folder> /grant <username>:F

/F – Full control
/R – Read-only


3. Take Ownership of a Folder

takeown /f <folder>

10. Advanced Commands

1. Run as Administrator

runas /user:Administrator cmd

2. Edit the Registry

regedit

3. Enable/Disable Services

sc config <service_name> start= disabled

4. View All Installed Drivers

driverquery

5. View All Installed Programs

wmic product get name

11. File Compression and Extraction

1. Zip Files

tar -a -cf archive.zip file.txt

2. Unzip Files

tar -xf archive.zip

12. Useful Shortcuts

Command Description
cls Clear screen
exit Close Command Prompt
title Set window title
color 0A Change text color
prompt $P$G Customize command prompt
ver Display Windows version
time Show current system time
date Show current system date
help List all commands
assoc View file associations

Tips for CMD

  • Use Tab to autocomplete file or folder names.
  • Use Ctrl + C to stop any running command.
  • Press Arrow Up to view the last executed command.
  • Use > to redirect output to a file (e.g., dir > files.txt).

With these basics, you can start mastering the Command Prompt.

Related posts

Linux curl Cheat Sheet

Linux apt Cheat Sheet

Linux wget Cheat Sheet