Getting Started

Opening Command Prompt

Windows 10, 11:

  • Press Win + R
  • Type cmd and press Enter
  • For administrator access: Right-click Command Prompt → "Run as administrator"

Keyboard Shortcuts

Shortcut Function
Tab Auto-complete folder/file names
↑/↓ Arrow Keys Navigate command history
Ctrl + C Cancel current command
Ctrl + V Paste text
Cls Clear screen

File Management Commands

Creating Files & Folders

Command Purpose Example
mkdir folder_name Create a new folder mkdir MyProject
md folder_name Same as mkdir (shorter) md Data
type nul > filename.txt Create empty file type nul > notes.txt
echo text > file.txt Create file with text echo Hello > greeting.txt

Copying & Moving Files

Command Purpose Example
copy source.txt dest.txt Copy file copy report.docx backup.docx
copy file.txt D:\Backup\ Copy to another location copy data.csv D:\Projects\
xcopy src dst /E /I Copy folders with contents xcopy C:\Data D:\Backup /E /I
move file.txt new_folder\ Move or rename file move old_name.txt new_name.txt
ren old_name.txt new_name.txt Rename file ren report.docx final.docx

Deleting Files & Folders

Command Purpose Example
del filename.txt Delete single file del temp.txt
del *.txt Delete all .txt files del *.txt
rmdir folder Delete empty folder rmdir OldFolder
rmdir /s folder Delete folder + contents rmdir /s /q Data

Viewing File Contents

Command Purpose Example
type file.txt Display entire file type readme.txt
more file.txt Display file page-by-page more document.txt
find "text" file.txt Search for text in file find "error" log.txt

System Information Commands

Check Your System

Command Purpose Example
systeminfo Display complete system info systeminfo
winver Show Windows version winver
tasklist List all running programs tasklist
tasklist /v Detailed process list tasklist /v
wmic cpu get name Get CPU model wmic cpu get name
wmic logicaldisk get name List all drives wmic logicaldisk get name
whoami Show current user whoami
date /t Show current date date /t
time /t Show current time time /t

Managing Running Programs

Command Purpose Example
taskkill /PID 1234 /F Force close program by PID taskkill /PID 1234 /F
taskkill /IM program.exe /F Force close program by name taskkill /IM notepad.exe /F

Network Diagnostics Commands

Command Purpose Example
ipconfig Show IP configuration ipconfig
ipconfig /all Detailed IP info ipconfig /all
ping google.com Test connection ping google.com
tracert google.com Trace network path tracert google.com
netstat -ano Show active connections netstat -ano
nslookup google.com Look up IP address nslookup google.com
getmac Show MAC address getmac

Python & Development Workflow

Managing Python Environments

Check Python Installation:

python --version

Create Virtual Environment:

python -m venv venv

Activate Virtual Environment:

venv\Scripts\activate

Deactivate Virtual Environment:

deactivate

Install Packages:

pip install package_name
pip install numpy pandas scikit-learn

View Installed Packages:

pip list

Create Requirements File:

pip freeze > requirements.txt

Install from Requirements:

pip install -r requirements.txt

Running Python Scripts

python script.py
python train_model.py --epochs 100

Conda Environment Management (for Anaconda Users)

conda create -n myenv python=3.9
conda activate myenv
conda install numpy pandas
conda deactivate

Advanced Tips & Tricks

1. Command Chaining & Redirection

Output Redirection:

dir > file_list.txt              :: Save output to file
dir >> file_list.txt             :: Append to file
command > nul                    :: Discard output

Piping (using output as input):

dir | find "txt"                 :: Find "txt" in directory listing
tasklist | find "python"         :: Find python processes

2. Using Wildcards

del *.tmp                        :: Delete all .tmp files
copy report*.xlsx Backup\        :: Copy files starting with "report"
ren *.txt *.bak                  :: Rename all .txt to .bak

3. Environment Variables

Common Variables:

%USERPROFILE%                   :: User's home directory
%TEMP%                          :: Temporary files folder
%PATH%                          :: System executable paths
%COMPUTERNAME%                  :: Computer name

Usage:

cd %USERPROFILE%\Documents      :: Go to user's Documents
echo %PATH%                     :: Show all PATH directories
dir %TEMP%                      :: View temp folder

4. Creating Batch Scripts

Create a file called backup.bat:

@echo off
REM This is a backup script
echo Starting backup...
xcopy C:\Work D:\Backups /E /H /C /I
echo Backup completed!
pause

Run it:

backup.bat

5. Navigating Efficiently

Save and return to directories:

pushd C:\path\to\folder        :: Save location and navigate
popd                           :: Return to saved location

Troubleshooting

Common Issues & Solutions

Problem Solution
"Command not recognized" Check command spelling; may need admin access
"Permission denied" Run Command Prompt as Administrator
"File not found" Check file exists; verify correct path and filename
"Access to folder denied" Take ownership or run as admin
Python not found Install Python or check PATH environment variable

Useful Verification Commands

dir C:\                         :: Verify you're at root
cd                             :: Show current directory
cls                            :: Clear screen if output is messy
help command_name              :: Get help for specific command
command /?                     :: Alternative help format

Linux to Windows Command Mapping

For those familiar with Linux, here's a quick reference:

Purpose Linux Windows
List files ls dir
Change directory cd cd
Make directory mkdir mkdir
Remove file rm del
Remove directory rm -r rmdir /s
Copy cp copy / xcopy
Move/rename mv move / ren
Clear screen clear cls
View file cat type
Search text grep find
Find files find dir /s
Copy recursively cp -r xcopy /E
Show path pwd cd
File comparison diff fc
Help man help or /?

Practice Exercises

Exercise 1: File Management

mkdir Practice
cd Practice
type nul > document.txt
copy document.txt document_backup.txt
dir

Exercise 2: System Information

systeminfo
tasklist | find "python"
ipconfig

Exercise 3: Python Environment

python -m venv test_env
test_env\Scripts\activate
pip list
deactivate
Remember: Always practice in a safe, non-critical directory first. Command Prompt is powerful—use it carefully!