Windows Command Prompt (CMD) Lab

Hands-on exercises for mastering basic Windows CMD operations

Lab Overview

This lab will teach you essential Windows Command Prompt commands for navigating the file system, managing files and folders, and performing basic operations. Complete each exercise in order.

Prerequisites: Windows 10/11 with Command Prompt access

Part 1: Opening Command Prompt

Methods to Open CMD:

  1. Windows Key + R → Type cmd → Press Enter
  2. Windows Key + X → Select "Windows Terminal" or "Command Prompt"
  3. Search Bar → Type "cmd" or "command prompt" → Press Enter
  4. File Explorer → Type cmd in address bar → Press Enter
Tip: For administrator privileges, right-click and select "Run as administrator"

Part 2: Navigation Commands

Essential Navigation Commands:

CommandDescriptionExample
cdDisplay current directorycd
cd [folder]Change to specified foldercd Documents
cd ..Go up one directory levelcd ..
cd \Go to root of current drivecd \
cd /d [drive:]Change to different drivecd /d D:\
dirList files and foldersdir
dir /wWide format listingdir /w
dir /pPaginated listingdir /p
treeDisplay folder structuretree
clsClear screencls

Exercise 1: Navigation Practice

Part 3: File Management Commands

File Operations:

CommandDescriptionExample
echo [text] > file.txtCreate file with textecho Hello World > test.txt
type nul > file.txtCreate empty filetype nul > empty.txt
type [file]Display file contentstype test.txt
copy [source] [dest]Copy filecopy test.txt backup.txt
move [source] [dest]Move/rename filemove test.txt newname.txt
ren [old] [new]Rename fileren oldfile.txt newfile.txt
del [file]Delete filedel test.txt
del *.txtDelete all .txt filesdel *.txt
attrib [file]View file attributesattrib test.txt
find "[text]" [file]Search text in filefind "hello" test.txt

Exercise 2: File Operations Practice

Setup: First, let's create a practice workspace and multiple files to work with
Step 1: Create Your Workspace
Step 2: Create Multiple Files
Step 3: Organize with Folders
Step 4: File Operations
Step 5: Advanced Operations
Step 6: Cleanup (Optional)
Great job! You've created multiple files and folders, organized them, and practiced essential file management operations. These are real-world skills you'll use frequently!

Part 4: Folder Management Commands

Folder Operations:

CommandDescriptionExample
mkdir [folder]Create new foldermkdir NewFolder
md [folder]Create folder (short)md TestFolder
mkdir [path\folder]Create nested foldersmkdir Parent\Child\Grandchild
rmdir [folder]Remove empty folderrmdir OldFolder
rd [folder]Remove folder (short)rd TestFolder
rmdir /s [folder]Remove folder and contentsrmdir /s FullFolder
rmdir /s /q [folder]Remove without confirmationrmdir /s /q TempFolder
move [folder] [dest]Move/rename foldermove OldName NewName
xcopy [source] [dest] /eCopy folder with contentsxcopy SourceDir DestDir /e
robocopy [src] [dest]Robust folder copyrobocopy Source Dest /e

Exercise 3: Folder Management Practice

Part 5: Advanced Commands & Tips

Useful Advanced Commands:

CommandDescriptionExample
helpList all commandshelp
help [command]Get help for specific commandhelp dir
[command] /?Command helpdir /?
tabAuto-complete pathsType partial name + Tab
↑ ↓Command historyArrow keys
F7Display command historyPress F7 key
command > file.txtRedirect output to filedir > listing.txt
command | morePage through outputdir | more
command1 && command2Run if first succeedsmkdir test && cd test
start [program]Launch programstart notepad

Pro Tips:

  • Use Tab key for auto-completion of file and folder names
  • Use quotes for paths with spaces: cd "Program Files"
  • Use * as wildcard: dir *.txt shows all .txt files
  • Chain commands with &&: mkdir test && cd test
  • Use cls to clear screen when it gets cluttered
  • Drag and drop files into CMD to auto-paste their paths
  • Right-click title bar → Properties to customize CMD appearance

Part 6: Final Challenge

Complete Project Structure Challenge

Create the following project structure using only CMD commands:

MyProject/
├── src/
│   ├── main.txt
│   └── config.txt
├── docs/
│   ├── readme.txt
│   └── notes.txt
├── backup/
└── temp/

Solution Steps:

Congratulations!

You've completed the Windows CMD basics lab! You now have the fundamental skills to navigate and manage files and folders using the command line. Practice these commands regularly to build muscle memory and efficiency.

Quick Reference Card

Navigation
  • cd - Show current directory
  • cd [folder] - Change directory
  • cd .. - Go up one level
  • dir - List contents
  • cls - Clear screen
File Operations
  • echo text > file - Create file
  • type file - View file
  • copy src dest - Copy file
  • move src dest - Move file
  • del file - Delete file
Folder Operations
  • mkdir folder - Create folder
  • rmdir folder - Remove empty folder
  • rmdir /s folder - Remove with contents
  • tree - Show folder structure
  • xcopy src dest /e - Copy folder
Helpful Shortcuts
  • Tab - Auto-complete
  • ↑ ↓ - Command history
  • F7 - History list
  • Ctrl+C - Cancel command
  • /? - Command help